
function Loding(CompaneyID, CompanyName, UserTypeId, Gid) {
    //autoComplete方法
    (function ($) {
        $.widget("ui.combobox", {
            _create: function () {
                var self = this,
					select = this.element.hide(),
					selected = select.children(":selected"),
					value = selected.val() ? selected.text() : "";
                var mark = select.attr("mark");
                var input = this.input = $("<input class=\"" + mark + "\">")
					.insertAfter(select)
					.val(value)
					.autocomplete({
					    delay: 0,
					    minLength: 0,
					    autoFocus: true,
					    source: function (request, response) {                                                        //request :输入的值 response:输出的值
					        var matcher = new RegExp($.ui.autocomplete.escapeRegex(request.term), "i");
					        response(select.children("option").map(function () {
					            var text = $(this).text();
					            var pinyin = $(this).attr("title");
					            //如果存在value值
					            if (this.value && this.title && (!request.term || matcher.test(text) || matcher.test(pinyin))) {
					                return {
					                    label: text.replace(
											new RegExp(
												"(?![^&;]+;)(?!<[^<>]*)(" +
												$.ui.autocomplete.escapeRegex(request.term) +
												")(?![^<>]*>)(?![^&;]+;)", "gi"
											), "<strong>$1</strong>"),
					                    value: text,
					                    option: this
					                };
					            }
					        }));
					    },
					    select: function (event, ui) {
					        ui.item.option.selected = true;
					        self._trigger("selected", event, {
					            item: ui.item.option
					        });
					        //获取选项value值
					        var ID = ui.item.option.value;
					        var TEXT = ui.item.option.text;
					        //找到当前选项的Mark值
					        var mark = $(this).prev("select").attr("Mark");
					        //获取分公司ID
					        var CompanyID = $("select[Mark='Company']").val();
					        //alert("CompanyID:"+CompanyID+"/ ID:"+ID);
					        //通过ajax给子City节点赋值
					        if (mark != "" && mark == "Company") {
					            $("#hdCompany").val(ID);
					            $("#hdCompanyName").val(TEXT);
					            if ($.isFunction(window.companyChange)) {
					                companyChange();
					            }
					            //粮库传递参数不为空
					            if (Gid != "") {
					                if (UserTypeId == "YHLX0101" || UserTypeId == "YHLX0102")   //总公司或者系统管理员
					                {
					                    //绑定粮库信息
					                    $.ajax({
					                        type: "Get",
					                        url: "../../Data/AutoComplete.ashx",
					                        data: "Function=GetGranaryByUserType&CompaneyID=" + CompanyID + "&CompanyName=" + CompanyName + "&UserTypeId=" + UserTypeId + "&GranaryDcExist=" + granaryDcExist,
					                        success: function (granaryInfo) {
					                            //alert(granaryInfo);
					                            $(".Granary_AutoComplete").find("option").remove();
					                            $(".Granary_AutoComplete").append(granaryInfo);
					                            //自动选择粮库
					                            $("#hdGranary").val($(".Granary_AutoComplete").find("option").eq(1).val());
					                            $("#hdGranaryName").val($(".Granary_AutoComplete").find("option").eq(1).text());
					                            $(".Granary_AutoComplete").next("input").val($(".Granary_AutoComplete").find("option").eq(1).text());
					                        }
					                    })
					                }
					                if (UserTypeId == "YHLX0103") {
					                    //绑定粮库信息
					                    var GidNow = Gid;
					                    if ($("#hdGranary").val() != "") {
					                        GidNow = $("#hdGranary").val();
					                    }

					                    var dataStr = "Function=GetGranaryByUserType&CompaneyID=" + $("#hdCompany").val() + "&CompanyName=" + CompanyName + "&UserTypeId=" + UserTypeId + "&GranaryDcExist=" + granaryDcExist;

					                    if ($("#hdDataSouse").length) {
					                        if ($("#hdDataSouse").val() == "One") {
					                            dataStr = "Function=GetGranaryByGid&CompaneyID=" + $("#hdCompany").val() + "&Gid=" + GidNow;
					                        }
					                    }
					                    $.ajax({
					                        type: "Get",
					                        url: "../../Data/AutoComplete.ashx",
					                        data: dataStr,
					                        success: function (granaryInfo) {
					                            //alert(granaryInfo);
					                            $(".Granary_AutoComplete").find("option").remove();
					                            //自动选择粮库
					                            $(".Granary_AutoComplete").append(granaryInfo);
					                            $("#hdGranary").val($(".Granary_AutoComplete").find("option").eq(1).val());
					                            $("#hdGranaryName").val($(".Granary_AutoComplete").find("option").eq(1).text());
					                            $(".Granary_AutoComplete").next("input").val($(".Granary_AutoComplete").find("option").eq(1).text());
					                        }
					                    })
					                }
					                if (UserTypeId == "YHLX0104" || UserTypeId == "YHLX0105" || UserTypeId == "YHLX0106") {

					                }
					            }
					            else {
					                if (UserTypeId != "YHLX0104" && UserTypeId != "YHLX0105" && UserTypeId != "YHLX0106")  //非粮库用户登陆
					                {
					                    $(".Granary_AutoComplete").next("input").val("");
					                    $(".Granary_AutoComplete").find("option").remove();
					                    $(".Granary_AutoComplete").append("<option value=\"\">Select one...</option>");        //消除只选择分公司，不提示“请选择粮库”的bug

					                    $.ajax({
					                        type: "Get",
					                        url: "../../Data/AutoComplete.ashx",
					                        data: "Function=GetGranaryByUserType&CompaneyID=" + CompanyID + "&CompanyName=" + CompanyName + "&UserTypeId=" + UserTypeId + "&GranaryDcExist=" + granaryDcExist,
					                        success: function (granaryInfo) {
					                            //alert(granaryInfo);
					                            $(".Granary_AutoComplete").next("input").val("");
					                            $(".Granary_AutoComplete").find("option").remove();

					                            $(".Granary_AutoComplete").combobox();
					                            //自动选择第一个选项
					                            if (isGranaryCheckAll == "true") {
					                                granaryInfo = "<option value=\"QuanBu\" title=\"QuanBu\">--全部--</option>" + granaryInfo;
					                            }

					                            $(".Granary_AutoComplete").append(granaryInfo);

					                            if (isGranaryCheckAll == "true") {
					                                $(".Granary_AutoComplete").next("input").val($(".Granary_AutoComplete").find("option").eq(0).text());
					                                $("#hdGranary").val($(".Granary_AutoComplete").find("option").eq(0).val());
					                                $("#hdGranaryName").val($(".Granary_AutoComplete").find("option").eq(0).text());
					                            }
					                            else {
					                                var text = $(".Granary_AutoComplete").find("option").eq(1).text();
					                                var value = $(".Granary_AutoComplete").find("option").eq(1).val();

					                                $("#hdGranary").val(value);
					                                $("#hdGranaryName").val(text);
					                                $(".Granary_AutoComplete").next("input").val(text);
					                            }
					                            var GranaryID = $("#hdGranary").val();
					                            if ($.isFunction(window.granaryChange)) {
					                                granaryChange();
					                            }
					                            //获取代储库信息
					                            if ($(".Granary_AutoComplete_DC").length) {
					                                $(".Granary_AutoComplete_DC").next("input").val("");
					                                $(".Granary_AutoComplete_DC").find("option").remove();
					                                $.ajax({
					                                    type: "Get",
					                                    url: "../../Data/AutoComplete.ashx",
					                                    data: "Function=GetSubGranary&GranaryID=" + GranaryID + "&LoginOrgCode=" + CompaneyID + "&LoginOrgName" + CompanyName + "&IsContainAll=" + IsContainAll + "&IsHaveOil=" + IsHaveOil,
					                                    success: function (granaryDCInfo) {
					                                        //alert(granaryDCInfo);
					                                        $(".Granary_AutoComplete_DC").append(granaryDCInfo);
					                                        $(".Granary_AutoComplete_DC").combobox();
					                                        Text = "";
					                                        $(".Granary_AutoComplete_DC").find("option").map(function () {
					                                            var value = $(this).val();
					                                            if (value == GranaryID) {
					                                                Text = $(this).text();
					                                                //选项被选中
					                                                //$(this).attr("Selected", "true");
					                                                $("#hdGranaryDC").val(value);
					                                                $("#hdGranaryNameDC").val(Text);
					                                            }
					                                        });
					                                        if (Text == "") {
					                                            //自动选择第一个
					                                            $("#hdGranaryDC").val($(".Granary_AutoComplete_DC").find("option").eq(1).val());
					                                            $("#hdGranaryNameDC").val($(".Granary_AutoComplete_DC").find("option").eq(1).text());
					                                            $(".Granary_AutoComplete_DC").next("input").val($(".Granary_AutoComplete_DC").find("option").eq(1).text());

					                                        }
					                                        else {
					                                            $(".Granary_AutoComplete_DC").next("input").val(Text);
					                                        }
					                                        if($.isFunction(window.granarydcChange))
					                                        {
					                                            granarydcChange();
					                                        }

					                                        //绑定油罐信息
					                                        if ($(".OilStore_AutoComplete").length || $("#hdOilStoreInfo").length) {
					                                            //清空仓房值
					                                            $("#hdOilStore").val("");
					                                            $("#hdOilStoreName").val("");

					                                            $.ajax({
					                                                type: "Get",
                                                                    cache:false,
					                                                url: "../../Data/AutoComplete.ashx",
					                                                data: "Function=GetOilTankByGranaryID&GranaryID=" + $("#hdGranaryDC").val() + "",
					                                                success: function (storeInfo) {
					                                                    $("#hdOilStoreInfo").val();
					                                                    $("td .OilTankTd").find("select").find("option").remove();
					                                                    $("#hdOilStoreInfo").val(storeInfo);
					                                                    $("td .OilTankTd").find("select").append("<option value='-1'>--请选择--</option>");
					                                                    $("td .OilTankTd").find("select").append(storeInfo);
					                                                    //alert(storeInfo);
					                                                    $(".OilStore_AutoComplete").next("input").val("");
					                                                    $(".OilStore_AutoComplete").find("option").remove();


					                                                    if (isStoreHouseCheckAll == "true" && storeInfo != "") {
					                                                        storeInfo = "<option value=\"QuanBu\" title=\"QuanBu\">--全部--</option>" + storeInfo;
					                                                    }

					                                                    $(".OilStore_AutoComplete").append(storeInfo);
					                                                    $(".OilStore_AutoComplete").combobox();

					                                                    if (isStoreHouseCheckAll == "true" && GranaryID != "") {

					                                                        $(".OilStore_AutoComplete").next("input").val($(".OilStore_AutoComplete").find("option").eq(0).text());
					                                                        $("#hdOilStore").val($(".Store_AutoComplete").find("option").eq(0).val());
					                                                        $("#hdOilStoreName").val($(".Granary_AutoComplete").find("option").eq(0).text());
					                                                    }
					                                                }
					                                            });
					                                        }
					                                    }
					                                });
					                            }

					                            //绑定仓房信息
					                            if ($(".Store_AutoComplete").length) {
					                                //清空仓房值
					                                $("#hdStore1").val("");
					                                $("#hdStoreName1").val("");
					                                $("#hdStore2").val("");
					                                $("#hdStoreName2").val("");

					                                $.ajax({
					                                    type: "Get",
					                                    url: "../../Data/AutoComplete.ashx",
					                                    data: "Function=GetStoreByGranaryID&GranaryID=" + GranaryID + "",
					                                    success: function (storeInfo) {
					                                        //alert(storeInfo);
					                                        $(".Store_AutoComplete").next("input").val("");
					                                        $(".Store_AutoComplete").find("option").remove();


					                                        if (isStoreHouseCheckAll == "true" && storeInfo != "") {
					                                            storeInfo = "<option value=\"QuanBu\" title=\"QuanBu\">--全部--</option>" + storeInfo;
					                                        }

					                                        $(".Store_AutoComplete").append(storeInfo);
					                                        $(".Store_AutoComplete").combobox();

					                                        if (isStoreHouseCheckAll == "true" && GranaryID != "") {

					                                            $(".Store_AutoComplete").next("input").val($(".Store_AutoComplete").find("option").eq(0).text());
					                                            $("#hdStore1").val($(".Store_AutoComplete").find("option").eq(0).val());
					                                            $("#hdStoreName1").val($(".Granary_AutoComplete").find("option").eq(0).text());

					                                            $("#hdStore2").val($(".Store_AutoComplete").find("option").eq(0).val());
					                                            $("#hdStoreName2").val($(".Granary_AutoComplete").find("option").eq(0).text());

					                                        }
					                                    }
					                                });
					                            }

					                            //绑定期数信息
					                            if ($(".CheckNum_AutoComplete").length) {
					                                //清空期数值
					                                $("#hdCheckNum").val("");
					                                $("#hdCheckNumName").val("");

					                                $.ajax({
					                                    type: "Get",
					                                    url: "../../Data/AutoComplete.ashx",
					                                    data: "Function=GetCheckNumByGranaryIDCompanyID&GranaryID=" + GranaryID + "&CompanyID=" + $("#hdCompany").val(),
					                                    success: function (checkNumInfo) {
					                                        //alert(checkNumInfo);
					                                        checkNumInfo = "<option value=\"QuanBu\" title=\"QuanBu\">--全部--</option>" + checkNumInfo;
					                                        $(".CheckNum_AutoComplete").next("input").val("");
					                                        $(".CheckNum_AutoComplete").find("option").remove();

					                                        $(".CheckNum_AutoComplete").append(checkNumInfo);
					                                        $(".CheckNum_AutoComplete").combobox();

					                                        //自动选择“--全部--”
					                                        $("#hdCheckNum").val($(".CheckNum_AutoComplete").find("option").eq(0).val());
					                                        $("#hdCheckNumName").val($(".CheckNum_AutoComplete").find("option").eq(0).text());
					                                        $(".CheckNum_AutoComplete").next("input").val($(".CheckNum_AutoComplete").find("option").eq(0).text());
					                                    }
					                                });
					                            }

					                            //绑定存储粮食类型信息
					                            if ($(".Type_AutoComplete").length) {
					                                $.ajax({
					                                    type: "Get",
					                                    url: "../../Data/AutoComplete.ashx",
					                                    data: "Function=GetGrainTypeByGranaryID&GranaryID=" + GranaryID + "",
					                                    success: function (grainTypeInfo) {
					                                        //alert(checkNumInfo);
					                                        $(".Type_AutoComplete").next("input").val("");
					                                        $(".Type_AutoComplete").find("option").remove();

					                                        $(".Type_AutoComplete").append(grainTypeInfo);
					                                        $(".Type_AutoComplete").combobox();
					                                    }
					                                });
					                            }

					                            //绑定测控日期
					                            if ($(".Time_AutoComplete").length) {
					                                //清空值
					                                $("#hdTime1").val("");
					                                $("#hdTimeValue1").val("");
					                                $("#hdTime2").val("");
					                                $("#hdTimeValue2").val("");
					                                $.ajax({
					                                    type: "Get",
					                                    url: "../../Data/AutoComplete.ashx",
					                                    data: "Function=GetTimeByGranaryIDStoreID&StoreID=-1&GranaryID=" + GranaryID + "",
					                                    success: function (dateInfo) {
					                                        //alert(dateInfo);
					                                        $(".Time_AutoComplete").next("input").val("");
					                                        $(".Time_AutoComplete").find("option").remove();

					                                        $(".Time_AutoComplete").append(dateInfo);
					                                        $(".Time_AutoComplete").combobox();
					                                    }
					                                });
					                            }
					                        }
					                    });

					                    if ($(".StoreHouseType_AutoComplete").length > 0) {
					                        var orgCode = $("#hdCompany").val();
					                        $.ajax({
					                            type: "Get",
					                            url: "../../Data/AutoComplete.ashx",
					                            data: "Function=GetDistinctStoreHouseTypeCodeByOrg&OrgCode=" + orgCode,
					                            success: function (dateInfo) {
					                                var jsonModel = $.parseJSON(dateInfo);
					                                $("#txtStoreHouseType").val("");
					                                $("#cblStoreHouseType").html("");
					                                var str = "";
					                                $.each(jsonModel, function (index, item) {
					                                    str += ('<div><input type="checkbox" value="' + item.TypeCode + '"/><label >' + item.TypeCode + '</label></div>');
					                                });
					                                if (str == '') {
					                                    str = '<div>无数据</div>';
					                                }
					                                $("#cblStoreHouseType").html(str);
					                            }
					                        });
					                    }
					                }

					                if (UserTypeId == "YHLX0104" || UserTypeId == "YHLX0105" || UserTypeId == "YHLX0106") //粮库用户登陆(直属库)
					                {
					                    $.ajax({
					                        type: "Get",
					                        url: "../../Data/AutoComplete.ashx",
					                        data: "Function=GetGranaryByUserType&CompaneyID=" + CompaneyID + "&CompanyName=" + CompanyName + "&UserTypeId=" + UserTypeId + "&GranaryDcExist=" + granaryDcExist,
					                        success: function (granaryInfo) {
					                            //alert(granaryInfo);
					                            $(".Granary_AutoComplete").next("input").val("");
					                            $(".Granary_AutoComplete").find("option").remove();
					                            $(".Granary_AutoComplete").append(granaryInfo);

					                            //自动选择第一个选项

					                            //$(".Granary_AutoComplete").find("option").eq(1).attr("Selected", "true");
					                            var value = $(".Granary_AutoComplete").find("option").eq(1).val();
					                            var text = $(".Granary_AutoComplete").find("option").eq(1).text();

					                            $("#hdGranary").val(value);
					                            $("#hdGranaryName").val(text);
					                            $(".Granary_AutoComplete").next("input").val(text);

					                            //请空仓房(RotaionPlan_Add.aspx使用到仓房)
					                            $(".Store_AutoComplete").next("input").val("");
					                            $(".Store_AutoComplete").find("option").remove();

					                            var GranaryID = value;

					                            //自动选择匹配代储库
					                            if ($(".Granary_AutoComplete_DC").length) {
					                                $(".Granary_AutoComplete_DC").next("input").val("");
					                                $(".Granary_AutoComplete_DC").find("option").remove();
					                                $.ajax({
					                                    type: "Get",
					                                    url: "../../Data/AutoComplete.ashx",
					                                    data: "Function=GetSubGranary&GranaryID=" + GranaryID + "&LoginOrgCode=" + CompaneyID + "&LoginOrgName" + CompanyName + "&IsContainAll=" + IsContainAll + "&IsHaveOil=" + IsHaveOil,
					                                    success: function (granaryDCInfo) {
					                                        $(".Granary_AutoComplete_DC").append(granaryDCInfo);
					                                        $(".Granary_AutoComplete_DC").combobox();

					                                        Text = "";
					                                        $(".Granary_AutoComplete_DC").find("option").map(function () {
					                                            var value = $(this).val();
					                                            if (value == GranaryID) {
					                                                Text = $(this).text();
					                                                //选项被选中
					                                                //$(this).attr("Selected", "true");
					                                                $("#hdGranaryDC").val(value);
					                                                $("#hdGranaryNameDC").val(Text);
					                                            }
					                                        });
					                                        if (Text == "") {
					                                            //自动选择第一个
					                                            $("#hdGranaryDC").val($(".Granary_AutoComplete_DC").find("option").eq(1).val());
					                                            $("#hdGranaryNameDC").val($(".Granary_AutoComplete_DC").find("option").eq(1).text());
					                                            $(".Granary_AutoComplete_DC").next("input").val($(".Granary_AutoComplete_DC").find("option").eq(1).text());

					                                        }
					                                        else {
					                                            $(".Granary_AutoComplete_DC").next("input").val(Text);
					                                        }

					                                        if($.isFunction(window.granarydcChange))
					                                        {
					                                            granarydcChange();
					                                        }


					                                        //绑定油罐信息
					                                        if ($(".OilStore_AutoComplete").length || $("#hdOilStoreInfo").length) {
					                                            //清空仓房值
					                                            $("#hdOilStore").val("");
					                                            $("#hdOilStoreName").val("");

					                                            $.ajax({
					                                                type: "Get",
					                                                cache: false,
					                                                url: "../../Data/AutoComplete.ashx",
					                                                data: "Function=GetOilTankByGranaryID&GranaryID=" + $("#hdGranaryDC").val() + "",
					                                                success: function (storeInfo) {
					                                                    $("#hdOilStoreInfo").val();
					                                                    $("td .OilTankTd").find("select").find("option").remove();
					                                                    $("#hdOilStoreInfo").val(storeInfo);
					                                                    $("td .OilTankTd").find("select").append("<option value='-1'>--请选择--</option>");
					                                                    $("td .OilTankTd").find("select").append(storeInfo);
					                                                    //alert(storeInfo);
					                                                    $(".OilStore_AutoComplete").next("input").val("");
					                                                    $(".OilStore_AutoComplete").find("option").remove();


					                                                    if (isStoreHouseCheckAll == "true" && storeInfo != "") {
					                                                        storeInfo = "<option value=\"QuanBu\" title=\"QuanBu\">--全部--</option>" + storeInfo;
					                                                    }

					                                                    $(".OilStore_AutoComplete").append(storeInfo);
					                                                    $(".OilStore_AutoComplete").combobox();

					                                                    if (isStoreHouseCheckAll == "true" && GranaryID != "") {

					                                                        $(".OilStore_AutoComplete").next("input").val($(".OilStore_AutoComplete").find("option").eq(0).text());
					                                                        $("#hdOilStore").val($(".Store_AutoComplete").find("option").eq(0).val());
					                                                        $("#hdOilStoreName").val($(".Granary_AutoComplete").find("option").eq(0).text());
					                                                    }
					                                                }
					                                            });
					                                        }
					                                    }
					                                });
					                            }
					                            
					                         

					                            //清空仓房值
					                            $("#hdStore1").val("");
					                            $("#hdStoreName1").val("");
					                            $("#hdStore2").val("");
					                            $("#hdStoreName2").val("");
					                            //清空时间值
					                            $("#hdTime1").val("");
					                            $("#hdTimeValue1").val("");
					                            $("#hdTime2").val("");
					                            $("#hdTimeValue2").val("");
					                            //重新绑定仓房
					                            $.ajax({
					                                type: "Get",
					                                url: "../../Data/AutoComplete.ashx",
					                                data: "Function=GetStoreByGranaryID&GranaryID=" + GranaryID + "",
					                                success: function (storeInfo) {
					                                    //alert(storeInfo);
					                                    $(".Store_AutoComplete").append(storeInfo);
					                                }
					                            });
					                        }
					                    });
					                }
					                //绑定存储粮食类型信息
					                if ($(".Type_AutoComplete1").length) {
					                    $.ajax({
					                        type: "Get",
					                        url: "../../Data/AutoComplete.ashx",
					                        data: "Function=GetGrainTypeByCompanyID&CompanyID=" + ID + "",
					                        success: function (grainTypeInfo) {
					                            //alert(checkNumInfo);
					                            $(".Type_AutoComplete1").next("input").val("");
					                            $(".Type_AutoComplete1").find("option").remove();

					                            $(".Type_AutoComplete1").append(grainTypeInfo);
					                        }
					                    });
					                }
					            }
					        }
					        //根据粮库ID获取库房信息/期数信息
					        if (mark != "" && mark == "Granary") {
					            $("#hdGranary").val(ID);
					            $("#hdGranaryName").val(TEXT);
					            if ($.isFunction(window.granaryChange)) {
					                granaryChange();
					            }
					            //自动选择第一个代储库
					            if ($(".Granary_AutoComplete_DC").length) {

					                //清空仓房值
					                $("#hdGranaryDC").val("");
					                $("#hdGranaryNameDC").val("");

					                $(".Granary_AutoComplete_DC").next("input").val("");
					                $(".Granary_AutoComplete_DC").find("option").remove();
					                $.ajax({
					                    type: "Get",
					                    url: "../../Data/AutoComplete.ashx",
					                    data: "Function=GetSubGranary&GranaryID=" + ID + "&LoginOrgCode=" + CompaneyID + "&LoginOrgName" + CompanyName + "&IsContainAll=" + IsContainAll + "&IsHaveOil=" + IsHaveOil,
					                    success: function (granaryDCInfo) {
					                        $(".Granary_AutoComplete_DC").append(granaryDCInfo);
					                        $(".Granary_AutoComplete_DC").combobox();

					                        Text = "";
					                        $(".Granary_AutoComplete_DC").find("option").map(function () {
					                            var value = $(this).val();
					                            if (value == ID) {
					                                Text = $(this).text();
					                                //选项被选中
					                                //$(this).attr("Selected", "true");
					                                $("#hdGranaryDC").val(value);
					                                $("#hdGranaryNameDC").val(Text);

					                                //自动绑定用户信息
					                                if ($("#ddlUser").length) {
					                                    $("#ddlUser").find("option").remove();
					                                    $.ajax({
					                                        type: "Get",
					                                        url: "../../Data/AutoComplete.ashx",
					                                        data: "Function=GetWaitWorkEmpowerUserList&GranaryID=" + ID + "&IsHaveOil=" + IsHaveOil,
					                                        success: function (userInfo) {
					                                            $("#ddlUser").append(userInfo);
					                                        }
					                                    })
					                                }
					                            }
					                        });
					                        if (Text == "") {
					                            //自动选择第一个
					                            $("#hdGranaryDC").val($(".Granary_AutoComplete_DC").find("option").eq(1).val());
					                            $("#hdGranaryNameDC").val($(".Granary_AutoComplete_DC").find("option").eq(1).text());
					                            $(".Granary_AutoComplete_DC").next("input").val($(".Granary_AutoComplete_DC").find("option").eq(1).text());
					                        }
					                        else {
					                            $(".Granary_AutoComplete_DC").next("input").val(Text);
					                        }
					                        if($.isFunction(window.granarydcChange))
					                        {
					                            granarydcChange();
					                        }

					                        //绑定油罐信息
					                        if ($(".OilStore_AutoComplete").length || $("#hdOilStoreInfo").length) {
					                            //清空仓房值
					                            $("#hdOilStore").val("");
					                            $("#hdOilStoreName").val("");
					                           
					                            $.ajax({
					                                type: "Get",
					                                cache: false,
					                                url: "../../Data/AutoComplete.ashx",
					                                data: "Function=GetOilTankByGranaryID&GranaryID=" + $("#hdGranaryDC").val() + "",
					                                success: function (storeInfo) {
					                                    $("#hdOilStoreInfo").val();
					                                    $("td .OilTankTd").find("select").find("option").remove();
					                                    $("#hdOilStoreInfo").val(storeInfo);
					                                    $("td .OilTankTd").find("select").append("<option value='-1'>--请选择--</option>");
					                                    $("td .OilTankTd").find("select").append(storeInfo);
					                                    //alert(storeInfo);
					                                    $(".OilStore_AutoComplete").next("input").val("");
					                                    $(".OilStore_AutoComplete").find("option").remove();


					                                    if (isStoreHouseCheckAll == "true" && storeInfo != "") {
					                                        storeInfo = "<option value=\"QuanBu\" title=\"QuanBu\">--全部--</option>" + storeInfo;
					                                    }

					                                    $(".OilStore_AutoComplete").append(storeInfo);
					                                    $(".OilStore_AutoComplete").combobox();

					                                    if (isStoreHouseCheckAll == "true" && GranaryID != "") {

					                                        $(".OilStore_AutoComplete").next("input").val($(".OilStore_AutoComplete").find("option").eq(0).text());
					                                        $("#hdOilStore").val($(".Store_AutoComplete").find("option").eq(0).val());
					                                        $("#hdOilStoreName").val($(".Granary_AutoComplete").find("option").eq(0).text());
					                                    }
					                                }
					                            });
					                        }
					                    }
					                });
					            }

					            //绑定仓房信息
					            if ($(".Store_AutoComplete").length) {
					                //清空仓房值
					                $("#hdStore1").val("");
					                $("#hdStoreName1").val("");
					                $("#hdStore2").val("");
					                $("#hdStoreName2").val("");

					                $.ajax({
					                    type: "Get",
					                    url: "../../Data/AutoComplete.ashx",
					                    data: "Function=GetStoreByGranaryID&GranaryID=" + ID + "",
					                    success: function (storeInfo) {
					                        //alert(storeInfo);
					                        $(".Store_AutoComplete").next("input").val("");
					                        $(".Store_AutoComplete").find("option").remove();

					                        if (isStoreHouseCheckAll == "true") {
					                            storeInfo = "<option value=\"QuanBu\" title=\"QuanBu\">--全部--</option>" + storeInfo;
					                        }

					                        $(".Store_AutoComplete").append(storeInfo);
					                        $(".Store_AutoComplete").combobox();

					                        if (isStoreHouseCheckAll == "true") {

					                            $(".Store_AutoComplete").next("input").val($(".Store_AutoComplete").find("option").eq(0).text());
					                            $("#hdStore1").val($(".Store_AutoComplete").find("option").eq(0).val());
					                            $("#hdStoreName1").val($(".Granary_AutoComplete").find("option").eq(0).text());

					                            $("#hdStore2").val($(".Store_AutoComplete").find("option").eq(0).val());
					                            $("#hdStoreName2").val($(".Granary_AutoComplete").find("option").eq(0).text());

					                        }
					                    }
					                });
					            }
					            //绑定期数信息
					            if ($(".CheckNum_AutoComplete").length) {
					                //清空期数值
					                $("#hdCheckNum").val("");
					                $("#hdCheckNumName").val("");

					                $.ajax({
					                    type: "Get",
					                    url: "../../Data/AutoComplete.ashx",
					                    data: "Function=GetCheckNumByGranaryIDCompanyID&GranaryID=" + ID + "&CompanyID=" + $("#hdCompany").val(),
					                    success: function (checkNumInfo) {
					                        //alert(checkNumInfo);

					                        $(".CheckNum_AutoComplete").next("input").val("");
					                        $(".CheckNum_AutoComplete").find("option").remove();

					                        checkNumInfo = "<option value=\"QuanBu\" title=\"QuanBu\">--全部--</option>" + checkNumInfo;

					                        $(".CheckNum_AutoComplete").append(checkNumInfo);
					                        $(".CheckNum_AutoComplete").combobox();

					                        //自动选择“--全部--”
					                        $("#hdCheckNum").val($(".CheckNum_AutoComplete").find("option").eq(0).val());
					                        $("#hdCheckNumName").val($(".CheckNum_AutoComplete").find("option").eq(0).text());
					                        $(".CheckNum_AutoComplete").next("input").val($(".CheckNum_AutoComplete").find("option").eq(0).text());
					                    }
					                });
					            }
					            //绑定测控日期
					            if ($(".Time_AutoComplete").length) {
					                //清空时间值
					                $("#hdTime1").val("");
					                $("#hdTimeValue1").val("");
					                $("#hdTime2").val("");
					                $("#hdTimeValue2").val("");

					                $.ajax({
					                    type: "Get",
					                    url: "../../Data/AutoComplete.ashx",
					                    data: "Function=GetTimeByGranaryIDStoreID&StoreID=-1&GranaryID=" + ID + "",
					                    success: function (dateInfo) {
					                        //alert(dateInfo);
					                        $(".Time_AutoComplete").next("input").val("");
					                        $(".Time_AutoComplete").find("option").remove();

					                        $(".Time_AutoComplete").append(dateInfo);
					                        $(".Time_AutoComplete").combobox();
					                    }
					                });
					            }

					            //绑定存储粮食类型信息
					            if ($(".Type_AutoComplete").length) {

					                $.ajax({
					                    type: "Get",
					                    url: "../../Data/AutoComplete.ashx",
					                    data: "Function=GetGrainTypeByGranaryID&GranaryID=" + ID + "",
					                    success: function (grainTypeInfo) {
					                        //alert(checkNumInfo);
					                        $(".Type_AutoComplete").next("input").val("");
					                        $(".Type_AutoComplete").find("option").remove();

					                        $(".Type_AutoComplete").append(grainTypeInfo);
					                        $(".Type_AutoComplete").combobox();
					                    }
					                });
					            }
					        }
					        //绑定代储库信息
					        if (mark != "" && mark == "GranaryDC") {
					            $("#hdGranaryDC").val(ID);
					            $("#hdGranaryNameDC").val(TEXT);
					            $(".Granary_AutoComplete_DC").next("input").val(TEXT);

					            //自动绑定用户信息
					            if ($("#ddlUser").length) {
					                $("#ddlUser").find("option").remove();
					                $.ajax({
					                    type: "Get",
					                    url: "../../Data/AutoComplete.ashx",
					                    data: "Function=GetWaitWorkEmpowerUserList&GranaryID=" + ID + "&IsHaveOil=" + IsHaveOil,
					                    success: function (userInfo) {
					                        $("#ddlUser").append(userInfo);
					                    }
					                })
					            }
					            if($.isFunction(window.granarydcChange))
					            {
					                granarydcChange();
					            }

					            //绑定油罐信息
					            if ($(".OilStore_AutoComplete").length || $("#hdOilStoreInfo").length) {
					                //清空仓房值
					                $("#hdOilStore").val("");
					                $("#hdOilStoreName").val("");

					                $.ajax({
					                    type: "Get",
					                    cache: false,
					                    url: "../../Data/AutoComplete.ashx",
					                    data: "Function=GetOilTankByGranaryID&GranaryID=" + $("#hdGranaryDC").val() + "",
					                    success: function (storeInfo) {
					                        $("#hdOilStoreInfo").val();
					                        $("td .OilTankTd").find("select").find("option").remove();
					                        $("#hdOilStoreInfo").val(storeInfo);
					                        $("td .OilTankTd").find("select").append("<option value='-1'>--请选择--</option>");
					                        $("td .OilTankTd").find("select").append(storeInfo);
					                        //alert(storeInfo);
					                        $(".OilStore_AutoComplete").next("input").val("");
					                        $(".OilStore_AutoComplete").find("option").remove();


					                        if (isStoreHouseCheckAll == "true" && storeInfo != "") {
					                            storeInfo = "<option value=\"QuanBu\" title=\"QuanBu\">--全部--</option>" + storeInfo;
					                        }

					                        $(".OilStore_AutoComplete").append(storeInfo);
					                        $(".OilStore_AutoComplete").combobox();

					                        if (isStoreHouseCheckAll == "true" && GranaryID != "") {

					                            $(".OilStore_AutoComplete").next("input").val($(".OilStore_AutoComplete").find("option").eq(0).text());
					                            $("#hdOilStore").val($(".Store_AutoComplete").find("option").eq(0).val());
					                            $("#hdOilStoreName").val($(".Granary_AutoComplete").find("option").eq(0).text());
					                        }
					                    }
					                });
					            }
					        }
					        //油罐选择
					        if (mark != "" && mark == "OilStore")
					        {
					            $("#hdOilStore").val(ID);
					            $("#hdOilStoreName").val(TEXT);
					            
					            if (ID!=null &&ID != "" && ID != "QuanBu")
					            {
					                 $.ajax({
					                    type: "POST",
					                    url: "../../Data/OilSpecialCardAjax.ashx",
					                    data: { Function: "GetOilTankInfoByOilTankID", oilTankID: ID },
					                    dataType: 'json',
					                    success: function (oilTankInfo) {
					                        $("#txtFillUnits").val($("#hdGranaryName").val());
					                        $("#txtStoreUnits").val(oilTankInfo.GranaryName);
					                        $("#txtOilTankName").val(oilTankInfo.OilTankName);
					                        $("#txtDesignCapacity").val(oilTankInfo.Capacity);
					                        $("#txtInDiameter").val(oilTankInfo.InDiameter);
					                        $("#txtStoreNum").val(oilTankInfo.RealCapacity);
					                        $("#txtPrice").val(oilTankInfo.Price);
					                        $("#txtInDateTime").val(oilTankInfo.InTimeString);
					                        $("#txtStorePlace").val(oilTankInfo.StorePlace);
					                        $("#txtMoisture").val(oilTankInfo.Moisture);
					                        $("#txtInsoluble").val(oilTankInfo.Insoluble);
					                        $("#txtPH").val(oilTankInfo.PH);
					                        $("#txtPeroxide").val(oilTankInfo.Peroxide);
					                        $("#txtSolventValue").val(oilTankInfo.SolventValue);
					                        $("#txtOilHeight").val(oilTankInfo.OilHeight);
					                        if ($.isFunction(window.oilTankChange))
					                            oilTankChange();
					                        $("#selectStoreOilType").find("option").map(function () {
					                            if (oilTankInfo.StoreTypeID == $(this).val()) {
					                                var strx = "";
					                                var selectId = $(this).val();
					                                $("#selectStoreOilType").find("option").remove();
					                                $.each(storeOilTypeList, function (i, item) {
					                                    var array = item.split(",");
					                                    if (selectId == array[0]) {
					                                        strx += ("<option value='" + array[0] + "' selected='true'>" + array[0] + "</option>");
					                                    }
					                                    else {
					                                        strx += ("<option value='" + array[0] + "'>" + array[0] + "</option>");
					                                    }
					                                });
					                                $("#selectStoreOilType").append(strx);
					                            }
					                        })

					                        $("#selectVarity").find("option").map(function () {
					                            if (oilTankInfo.VarietyID == $(this).val())
					                            {
					                                var strx = "";
					                                var selectId = $(this).val();
					                                $("#selectVarity").find("option").remove();
					                                $.each(varityList, function (i, item) {
					                                    var array = item.split(",");
					                                    if (selectId == array[0]) {
					                                        strx += ("<option value='" + array[0] + "' selected='true'>" + array[1] + "</option>");
					                                    }
					                                    else {
					                                        strx += ("<option value='" + array[0] + "'>" + array[1] + "</option>");
					                                    }
					                                });
					                                $("#selectVarity").append(strx);
					                            }
					                        })


					                        $("#selectProcessTime").find("option").map(function () {
					                            if (oilTankInfo.ProcessTime == $(this).text()) {
					                                var strx = "";
					                                var selectId = $(this).val();
					                                $("#selectProcessTime").find("option").remove();
					                                $.each(processTimeList, function (i, item) {
					                                    if (selectId == i) {
					                                        strx += ("<option value='" + i + "' selected='true'>" + item + "</option>");
					                                    }
					                                    else {
					                                        strx += ("<option value='" + i + "'>" + item + "</option>");
					                                    }
					                                });
					                                $("#selectProcessTime").append(strx);
					                            }
					                        })

					                        $("#selectGrade").find("option").map(function () {
					                            if (oilTankInfo.GradeID == $(this).val()) {
					                                var strx = "";
					                                var selectId = $(this).val();
					                                $("#selectGrade").find("option").remove();
					                                $.each(gradeList, function (i, item) {
					                                    var array = item.split(",");
					                                    if (selectId == array[0]) {
					                                        strx += ("<option value='" + array[0] + "' selected='true'>" + array[1] + "</option>");
					                                    }
					                                    else {
					                                        strx += ("<option value='" + array[0] + "'>" + array[1] + "</option>");
					                                    }
					                                });
					                                $("#selectGrade").append(strx);
					                            }
					                        })
					                    }
					                });
					           }
					        }

					        //根据仓房ID获取时间（HouseComp.aspx）
					        if (mark != "" && mark == "Store") {

					            //绑定仓房信息
					            var GranaryID = $("#hdGranary").val();  //获取粮库ID

					            var storeLength = $(".Store_AutoComplete").length;
					            //alert(storeLength);
					            for (var indexi = 0; indexi < storeLength; indexi++) {

					                var id = $(this).prev("select").attr("id");
					                if (id == "ddl_Store_AutoComplete" + (indexi + 1)) {
					                    $("#hdStore" + (indexi + 1)).val(ID);
					                    $("#hdStoreName" + (indexi + 1)).val(TEXT);

					                    var indexNum = indexi;

					                    //清空时间值
					                    $("#hdTime" + (indexi + 1)).val("");
					                    $("#hdTimeVlaue" + (indexi + 1)).val("");

					                    //清空时间值
					                    $(".Time_AutoComplete").eq(indexNum).next("input").val("");
					                    $(".Time_AutoComplete").eq(indexNum).find("option").remove();

					                    $.ajax({
					                        type: "Get",
					                        url: "../../Data/AutoComplete.ashx",
					                        data: "Function=GetTimeByGranaryIDStoreID&StoreID=" + ID + "&GranaryID=" + GranaryID + "",
					                        success: function (timeInfo) {
					                            //alert(timeInfo);
					                            $(".Time_AutoComplete").eq(indexNum).append(timeInfo);
					                            //自动选择第一项
					                            $("#hdTime" + (indexNum + 1)).val($(".Time_AutoComplete").eq(indexNum).find("option").eq(1).val());
					                            $("#hdTimeVlaue" + (indexNum + 1)).val($(".Time_AutoComplete").eq(indexNum).find("option").eq(1).text());
					                            $(".Time_AutoComplete").eq(indexNum).next("input").val($(".Time_AutoComplete").eq(indexNum).find("option").eq(1).text());
					                        }
					                    });
					                }
					            }
					            if (typeof ShowTime == "function") {
					                ShowTime(CompaneyID, GranaryID, ID);
					            }
					        }

					        //获取选择期数
					        if (mark != "" && mark == "CheckNum") {
					            $("#hdCheckNum").val(ID);
					            $("#hdCheckNumName").val(TEXT);
					        }

					        //获取时间
					        if (mark != "" && mark == "Time") {

					            var GranaryID = $("#hdGranary").val();  //获取粮库ID

					            var timeLength = $(".Time_AutoComplete").length;
					            //alert(timeLength);

					            for (var indexi = 0; indexi < timeLength; indexi++) {

					                var id = $(this).prev("select").attr("id");
					                if (id == "ddl_Time_AutoComplete" + (indexi + 1)) {
					                    $("#hdTime" + (indexi + 1)).val(ID);
					                    $("#hdTimeValue" + (indexi + 1)).val(TEXT);
					                }
					            }
					        }
					    },
					    change: function (event, ui) {
					        if (!ui.item) {
					            var matcher = new RegExp("^" + $.ui.autocomplete.escapeRegex($(this).val()) + "$", "i"),
									valid = false;
					            select.children("option").each(function () {
					                if ($(this).text().match(matcher)) {
					                    this.selected = valid = true;
					                    return false;
					                }
					            });
					            if (!valid) {
					                // remove invalid value, as it didn't match anything
					                $(this).val("");
					                select.val("");
					                input.data("autocomplete").term = "";
					                if (mark != "" && mark == "Company") {
					                    //清空分公司后的子项
					                    if ($(".Company_AutoComplete").val() == "") {
					                        //清空分公司值
					                        $("#hdCompany").val("");
					                        $("#hdCompanyName").val("");
					                        //清空粮库值
					                        $("#hdGranary").val("");
					                        $("#hdGranaryName").val("");
					                        //清空粮库选项
					                        $(".Granary_AutoComplete").next("input").val("");
					                        $(".Granary_AutoComplete").find("option").remove();
					                        $(".Granary_AutoComplete").append("<option value=\"\">Select one...</option>");    //消除当清空分公司选项后，然后只选择分公司，点击查询，不提示“请选择粮库”的bug
					                    }
					                    //清空仓房值
					                    $("#hdStore1").val("");
					                    $("#hdStoreName1").val("");
					                    $("#hdStore2").val("");
					                    $("#hdStoreName2").val("");
					                    //清空仓房选项
					                    $(".Store_AutoComplete").next("input").val("");
					                    $(".Store_AutoComplete").find("option").remove();
					                    $(".Store_AutoComplete").append("<option value=\"\">Select one...</option>");

					                    //清空期数值
					                    $("#hdCheckNum").val("");
					                    $("#hdCheckNumName").val("");
					                    //清空期数选项
					                    $(".CheckNum_AutoComplete").next("input").val("");
					                    $(".CheckNum_AutoComplete").find("option").remove();
					                    $(".CheckNum_AutoComplete").append("<option value=\"\">Select one...</option>");

					                    //清空时间值
					                    $("#hdTime1").val("");
					                    $("#hdTimeValue1").val("");
					                    $("#hdTime2").val("");
					                    $("#hdTimeValue2").val("");
					                    //清空时间选项
					                    $(".Time_AutoComplete").next("input").val("");
					                    $(".Time_AutoComplete").find("option").remove();
					                    $(".Time_AutoComplete").append("<option value=\"\">Select one...</option>");

					                    //清空粮食类型值
					                    $("#hdType").val("");
					                    //清空存储粮食类型选项
					                    $(".Type_AutoComplete").next("input").val("");
					                    $(".Type_AutoComplete").find("option").remove();
					                    $(".Type_AutoComplete").append("<option value=\"\">Select one...</option>");
					                }
					                if (mark != "" && mark == "Granary") {

					                    //清空粮库值
					                    $("#hdGranary").val("");
					                    $("#hdGranaryName").val("");

					                    //清空城市和粮库的选项
					                    if ($(".Granary_AutoComplete").val() == "") {
					                        //清空仓房值
					                        $("#hdStore1").val("");
					                        $("#hdStoreName1").val("");
					                        $("#hdStore2").val("");
					                        $("#hdStoreName2").val("");
					                        //清空代储库选项
					                        $(".Granary_AutoComplete_DC").next("input").val("");
					                        $(".Granary_AutoComplete_DC").find("option").remove();
					                        $(".Granary_AutoComplete_DC").append("<option value=\"\">Select one...</option>");

					                        //清空仓房选项
					                        $(".Store_AutoComplete").next("input").val("");
					                        $(".Store_AutoComplete").find("option").remove();
					                        $(".Store_AutoComplete").append("<option value=\"\">Select one...</option>");

					                        //清空期数值
					                        $("#hdCheckNum").val("");
					                        $("#hdCheckNumName").val("");
					                        //清空期数选项
					                        $(".CheckNum_AutoComplete").next("input").val("");
					                        $(".CheckNum_AutoComplete").find("option").remove();
					                        $(".CheckNum_AutoComplete").append("<option value=\"\">Select one...</option>");

					                        //清空时间值
					                        $("#hdTime1").val("");
					                        $("#hdTimeValue1").val("");
					                        $("#hdTime2").val("");
					                        $("#hdTimeValue2").val("");
					                        //清空时间选项
					                        $(".Time_AutoComplete").next("input").val("");
					                        $(".Time_AutoComplete").find("option").remove();
					                        $(".Time_AutoComplete").append("<option value=\"\">Select one...</option>");

					                        //清空粮食类型值
					                        $("#hdType").val("");
					                        //清空存储粮食类型选项
					                        $(".Type_AutoComplete").next("input").val("");
					                        $(".Type_AutoComplete").find("option").remove();
					                        $(".Type_AutoComplete").append("<option value=\"\">Select one...</option>");
					                    }
					                }
					                return false;
					            }
					        }
					    }
					})
					.addClass("ui-widget ui-widget-content ui-corner-left");

                input.data("autocomplete")._renderItem = function (ul, item) {
                    return $("<li></li>")
						.data("item.autocomplete", item)
						.append("<a style=\"font-size:12px;\">" + item.label + "</a>")
						.appendTo(ul).parent("ul").css({ "height": "250px", "overflow-y": "auto", "overflow-x": "hidden" });         //控制下拉框的高度，及滚动条
                };
                var bro = $.browser;
                var height = "24";

                this.button = $("<button type='button' style=\"font-size:12px;\">&nbsp;</button>")
					.attr("tabIndex", -1)
					.attr("title", "显示全部信息！")
					.insertAfter(input)
					.button({
					    icons: {
					        primary: "ui-icon-triangle-1-s"
					    },
					    text: false
					})
					.removeClass("ui-corner-all")
					.addClass("ui-corner-right .ui-button-icon-only")
                    .css("height", height)
					.click(function () {
					    // close if already visible
					    if (input.autocomplete("widget").is(":visible")) {
					        input.autocomplete("close");
					        return;
					    }

					    // work around a bug (likely same cause as #5265)
					    $(this).blur();

					    // pass empty string as value to search for, displaying all results
					    input.autocomplete("search", "");
					    input.focus();
					});
            },

            destroy: function () {
                this.input.remove();
                this.button.remove();
                this.element.show();
                $.Widget.prototype.destroy.call(this);
            }
        });
    })(jQuery);
    //参数赋值
    var CGid = "";
    if ($("#hdDataSouse").length) {
        if ($("#hdDataSouse").val() == "One") {
            CGid = Gid;
        }
        if ($("#hdDataSouse").val() == "All") {
            CGid = "";
        }
    }
    //设置是否需要“全选”
    var isCompanyCheckAll = "false";    //默认为不需要全选
    var isGranaryCheckAll = "false";
    var isStoreHouseCheckAll = "false";

    //根据页面设置的属性，进行赋值
    if ($("#hdCompanyCheckAll").length) {
        isCompanyCheckAll = $("#hdCompanyCheckAll").val();
    }

    if ($("#hdGranaryCheckAll").length) {
        isGranaryCheckAll = $("#hdGranaryCheckAll").val();
    }

    if ($("#hdStoreHouseCheckAll").length) {
        isStoreHouseCheckAll = $("#hdStoreHouseCheckAll").val();
    }

    //判断页面是否需要分开显示代储库信息
    var granaryDcExist = "false";

    if ($(".Granary_AutoComplete_DC").length) {
        granaryDcExist = "true";
    }

    if ($("#hdOnlyShowGranarySA").length)
    {
        granaryDcExist = $("#hdOnlyShowGranarySA").val();
    }

    //判断代储库是否显示“全部”
    var IsContainAll = "y";

    if ($("#hdShowAll").length) {
        IsContainAll = $("#hdShowAll").val();
    }

    //判断代储库是否显示只存储油脂的

    var IsHaveOil = "false";

    if ($("#hdIsHaveOil").length)
    {
        IsHaveOil = $("#hdIsHaveOil").val();
    }

    //首先加载分公司信息
    $.ajax({
        type: "Get",
        url: "../../Data/AutoComplete.ashx",
        data: "Function=GetCompanyByUserType&CompaneyID=" + CompaneyID + "&CompanyName=" + CompanyName + "&UserTypeId=" + UserTypeId + "&Gid=" + CGid + "&CompanyCheckAll=" + isCompanyCheckAll,
        success: function (companyInfo) {
            //alert(companyInfo);
            //传递参数gid不为空
            if (Gid != "") {
                $(".Company_AutoComplete").find("option").remove();
                $(".Company_AutoComplete").append(companyInfo);
                //调用AutoComplete
                $(".Company_AutoComplete").combobox();

                var GidNow = "";

                if ($("#hdGranary").val() == "") {
                    GidNow = Gid;
                }
                else {
                    GidNow = $("#hdGranary").val();
                }

                if (UserTypeId == "YHLX0101" || UserTypeId == "YHLX0102") //登陆用户为总公司或者系统管理员
                {
                    $.ajax({
                        type: "Get",
                        url: "../../Data/AutoComplete.ashx",
                        data: "Function=GetCompanyIdByGid&Gid=" + GidNow,
                        success: function (companyId) {
                            //选中分公司id为gCompanyId的选项
                            var Text = "";
                            $(".Company_AutoComplete").find("option").map(function () {
                                var value = $(this).val();
                                if (value == companyId) {
                                    Text = $(this).text();
                                    //选项被选中
                                    //$(this).attr("Selected", "true");
                                    $("#hdCompany").val(value);
                                    $("#hdCompanyName").val(Text);

                                    //alert("123");
                                }
                            });

                            $(".Company_AutoComplete").next("input").val(Text);
                            //绑定粮库信息
                            $.ajax({
                                type: "Get",
                                url: "../../Data/AutoComplete.ashx",
                                data: "Function=GetGranaryByUserType&CompaneyID=" + companyId + "&CompanyName=" + CompanyName + "&UserTypeId=" + UserTypeId + "&GranaryDcExist=" + granaryDcExist,
                                success: function (granaryInfo) {
                                    //alert(granaryInfo);
                                    $(".Granary_AutoComplete").find("option").remove();
                                    $(".Granary_AutoComplete").append(granaryInfo);
                                    $(".Granary_AutoComplete").combobox();
                                    //根据gid自动选择匹配粮库
                                    var Text = "";
                                    $(".Granary_AutoComplete").find("option").map(function () {
                                        var value = $(this).val();
                                        if (value == GidNow) {
                                            Text = $(this).text();

                                            //选项被选中
                                            $("#hdGranary").val(value);
                                            $("#hdGranaryName").val(Text);
                                        }
                                    });

                                    //绑定代储库
                                    if ($(".Granary_AutoComplete_DC").length) {
                                        $(".Granary_AutoComplete_DC").next("input").val("");
                                        $(".Granary_AutoComplete_DC").find("option").remove();
                                        $.ajax({
                                            type: "Get",
                                            url: "../../Data/AutoComplete.ashx",
                                            data: "Function=GetSubGranary&GranaryID=" + $("#hdGranary").val() + "&LoginOrgCode=" + CompaneyID + "&LoginOrgName=" + CompanyName + "&IsContainAll=" + IsContainAll+"&IsHaveOil="+IsHaveOil,
                                            success: function (granaryDCInfo) {
                                                $(".Granary_AutoComplete_DC").append(granaryDCInfo);
                                                $(".Granary_AutoComplete_DC").combobox();

                                                Text = "";
                                                $(".Granary_AutoComplete_DC").find("option").map(function () {
                                                    var value = $(this).val();
                                                    if (value == $("#hdGranaryDC").val()) {
                                                        Text = $(this).text();
                                                        //选项被选中
                                                        //$(this).attr("Selected", "true");
                                                        $("#hdGranaryDC").val(value);
                                                        $("#hdGranaryNameDC").val(Text);
                                                    }
                                                });
                                                if (Text == "") {
                                                    //自动选择第一个
                                                    $("#hdGranaryDC").val($(".Granary_AutoComplete_DC").find("option").eq(1).val());
                                                    $("#hdGranaryNameDC").val($(".Granary_AutoComplete_DC").find("option").eq(1).text());
                                                    $(".Granary_AutoComplete_DC").next("input").val($(".Granary_AutoComplete_DC").find("option").eq(1).text());

                                                }
                                                else {
                                                    $(".Granary_AutoComplete_DC").next("input").val(Text);
                                                }
                                                if ($.isFunction(window.granarydcChange)) {
                                                    granarydcChange();
                                                }
                                            }
                                        });
                                    }
                                    $(".Granary_AutoComplete").next("input").val(Text);

                                    //绑定仓房信息
                                    if ($(".Store_AutoComplete").length) {

                                        $(".Store_AutoComplete").next("input").val("");
                                        $(".Store_AutoComplete").find("option").remove();
                                        $.ajax({
                                            type: "Get",
                                            url: "../../Data/AutoComplete.ashx",
                                            data: "Function=GetStoreByGranaryID&GranaryID=" + $("#hdGranary").val() + "",
                                            success: function (storeInfo) {
                                                //alert(storeInfo);
                                                $(".Store_AutoComplete").append(storeInfo);
                                                $(".Store_AutoComplete").combobox();

                                                Text = "";
                                                var storeHouseID = $("#hdStore1").val();
                                                $(".Store_AutoComplete").find("option").map(function () {
                                                    var value = $(this).val();
                                                    if (value == storeHouseID) {
                                                        Text = $(this).text();
                                                        //选项被选中
                                                        $("#hdStore1").val(value);

                                                        $(".Store_AutoComplete").next("input").val(Text);
                                                    }
                                                });
                                            }
                                        });
                                    }
                                }
                            });
                        }
                    })
                }
                if (UserTypeId == "YHLX0103")                    //登陆用户为分公司
                {
                    //自动选择第一个分公司
                    $.ajax({
                        type: "Get",
                        url: "../../Data/AutoComplete.ashx",
                        data: "Function=GetCompanyIdByGid&Gid=" + GidNow,
                        success: function (companyId) {
                            //选中分公司id为gCompanyId的选项
                            var Text = "";
                            $(".Company_AutoComplete").find("option").map(function () {
                                var value = $(this).val();
                                if (value == companyId) {
                                    Text = $(this).text();
                                    //选项被选中
                                    $("#hdCompany").val(value);
                                    $("#hdCompanyName").val(Text);
                                }
                            });
                            $(".Company_AutoComplete").next("input").val(Text);

                            var dataStr = "Function=GetGranaryByUserType&CompaneyID=" + $("#hdCompany").val() + "&CompanyName=" + CompanyName + "&UserTypeId=" + UserTypeId + "&GranaryDcExist=" + granaryDcExist;
                            if ($("#hdDataSouse").length) {

                                if ($("#hdDataSouse").val() == "One") {
                                    dataStr = "Function=GetGranaryByGid&CompaneyID=" + $("#hdCompany").val() + "&Gid=" + Gid;
                                }
                            }
                            //alert(dataStr);
                            //绑定粮库信息
                            $.ajax({
                                type: "Get",
                                url: "../../Data/AutoComplete.ashx",
                                data: dataStr,
                                success: function (granaryInfo) {
                                    //alert(granaryInfo);
                                    $(".Granary_AutoComplete").find("option").remove();
                                    $(".Granary_AutoComplete").append(granaryInfo);
                                    $(".Granary_AutoComplete").combobox();
                                    //自动选择粮库
                                    if ($("#hdGranary").val() == "" && Gid == "") {
                                        $("#hdGranary").val($(".Granary_AutoComplete").find("option").eq(1).val());
                                        $("#hdGranaryName").val($(".Company_AutoComplete").find("option").eq(1).text());
                                        $(".Granary_AutoComplete").next("input").val($(".Granary_AutoComplete").find("option").eq(1).text());
                                    }
                                    else {
                                        var GidNow = Gid;
                                        if ($("#hdGranary").val() != "") {
                                            GidNow = $("#hdGranary").val();
                                        }
                                        var Text = "";
                                        $(".Granary_AutoComplete").find("option").map(function () {
                                            var value = $(this).val();
                                            if (value == GidNow) {
                                                Text = $(this).text();
                                                //选项被选中
                                                //$(this).attr("Selected", "true");
                                                $("#hdGranary").val(value);
                                                $("#hdGranaryName").val(Text);
                                            }
                                        });
                                        $(".Granary_AutoComplete").next("input").val(Text);
                                    }

                                    //绑定代储库
                                    if ($(".Granary_AutoComplete_DC").length) {
                                        $(".Granary_AutoComplete_DC").next("input").val("");
                                        $(".Granary_AutoComplete_DC").find("option").remove();
                                        $.ajax({
                                            type: "Get",
                                            url: "../../Data/AutoComplete.ashx",
                                            data: "Function=GetSubGranary&GranaryID=" + $("#hdGranary").val() + "&LoginOrgCode=" + CompaneyID + "&LoginOrgName=" + CompanyName + "&IsContainAll=" + IsContainAll + "&IsHaveOil=" + IsHaveOil,
                                            success: function (granaryDCInfo) {
                                                //alert(granaryDCInfo);
                                                $(".Granary_AutoComplete_DC").append(granaryDCInfo);
                                                $(".Granary_AutoComplete_DC").combobox();

                                                Text = "";
                                                $(".Granary_AutoComplete_DC").find("option").map(function () {
                                                    var value = $(this).val();
                                                    if (value == $("#hdGranaryDC").val()) {
                                                        Text = $(this).text();
                                                        //选项被选中
                                                        //$(this).attr("Selected", "true");
                                                        $("#hdGranaryDC").val(value);
                                                        $("#hdGranaryNameDC").val(Text);
                                                    }
                                                });
                                                if (Text == "") {
                                                    //自动选择第一个
                                                    $("#hdGranaryDC").val($(".Granary_AutoComplete_DC").find("option").eq(1).val());
                                                    $("#hdGranaryNameDC").val($(".Granary_AutoComplete_DC").find("option").eq(1).text());
                                                    $(".Granary_AutoComplete_DC").next("input").val($(".Granary_AutoComplete_DC").find("option").eq(1).text());

                                                }
                                                else {
                                                    $(".Granary_AutoComplete_DC").next("input").val(Text);
                                                }
                                                if ($.isFunction(window.granarydcChange)) {
                                                    granarydcChange();
                                                }
                                            }
                                        });
                                    }

                                    //绑定仓房信息
                                    if ($(".Store_AutoComplete").length) {

                                        $(".Store_AutoComplete").next("input").val("");
                                        $(".Store_AutoComplete").find("option").remove();
                                        $.ajax({
                                            type: "Get",
                                            url: "../../Data/AutoComplete.ashx",
                                            data: "Function=GetStoreByGranaryID&GranaryID=" + $("#hdGranary").val() + "",
                                            success: function (storeInfo) {
                                                //alert(storeInfo);
                                                $(".Store_AutoComplete").append(storeInfo);
                                                $(".Store_AutoComplete").combobox();

                                                Text = "";
                                                var storeHouseID = $("#hdStore1").val();
                                                $(".Store_AutoComplete").find("option").map(function () {
                                                    var value = $(this).val();
                                                    if (value == storeHouseID) {
                                                        Text = $(this).text();
                                                        //选项被选中
                                                        $("#hdStore1").val(value);

                                                        $(".Store_AutoComplete").next("input").val(Text);
                                                    }
                                                });
                                            }
                                        });
                                    }
                                }
                            })
                        }
                    });
                }

                if (UserTypeId == "YHLX0104" || UserTypeId == "YHLX0105" || UserTypeId == "YHLX0106")          //粮库登陆
                {
                    //自动选择第一个分公司
                    //$(".Company_AutoComplete").find("option").eq(1).attr("Selected", "true");
                    $("#hdCompany").val($(".Company_AutoComplete").find("option").eq(1).val());
                    $("#hdCompanyName").val($(".Company_AutoComplete").find("option").eq(1).text());
                    $(".Company_AutoComplete").next("input").val($(".Company_AutoComplete").find("option").eq(1).text());

                    //绑定粮库信息
                    var GidNow = "";
                    if ($("#hdGranary").val() == "") {
                        GidNow = Gid;
                    }
                    else {
                        GidNow = $("#hdGranary").val();
                    }
                    $.ajax({
                        type: "Get",
                        url: "../../Data/AutoComplete.ashx",
                        data: "Function=GetGranaryByUserType&CompaneyID=" + CompaneyID + "&CompanyName=" + CompanyName + "&UserTypeId=" + UserTypeId + "&GranaryDcExist=" + granaryDcExist,
                        success: function (granaryInfo) {
                            //alert(granaryInfo);
                            $(".Granary_AutoComplete").find("option").remove();
                            $(".Granary_AutoComplete").append(granaryInfo);

                            $(".Granary_AutoComplete").combobox();
                            //根据GidNow选中匹配粮库
                            $(".Granary_AutoComplete").find("option").map(function () {
                                var value = $(this).val();
                                if (value == GidNow) {
                                    Text = $(this).text();
                                    //选项被选中
                                    $("#hdGranary").val(value);
                                    $("#hdGranaryName").val(Text);
                                }
                            });
                            $(".Granary_AutoComplete").next("input").val(Text);

                            //绑定代储库
                            if ($(".Granary_AutoComplete_DC").length) {
                                $(".Granary_AutoComplete_DC").next("input").val("");
                                $(".Granary_AutoComplete_DC").find("option").remove();
                                $.ajax({
                                    type: "Get",
                                    url: "../../Data/AutoComplete.ashx",
                                    data: "Function=GetSubGranary&GranaryID=" + $("#hdGranary").val() + "&LoginOrgCode=" + CompaneyID + "&LoginOrgName=" + CompanyName + "&IsContainAll=" + IsContainAll + "&IsHaveOil=" + IsHaveOil,
                                    success: function (granaryDCInfo) {
                                        $(".Granary_AutoComplete_DC").append(granaryDCInfo);
                                        $(".Granary_AutoComplete_DC").combobox();

                                        Text = "";
                                        $(".Granary_AutoComplete_DC").find("option").map(function () {
                                            var value = $(this).val();
                                            if (value == $("#hdGranaryDC").val()) {
                                                Text = $(this).text();
                                                //选项被选中
                                                $("#hdGranaryDC").val(value);
                                                $("#hdGranaryNameDC").val(Text);
                                            }
                                        });
                                        if (Text == "") {
                                            //自动选择第一个
                                            $("#hdGranaryDC").val($(".Granary_AutoComplete_DC").find("option").eq(1).val());
                                            $("#hdGranaryNameDC").val($(".Granary_AutoComplete_DC").find("option").eq(1).text());
                                            $(".Granary_AutoComplete_DC").next("input").val($(".Granary_AutoComplete_DC").find("option").eq(1).text());

                                        }
                                        else {
                                            $(".Granary_AutoComplete_DC").next("input").val(Text);
                                        }
                                        if ($.isFunction(window.granarydcChange)) {
                                            granarydcChange();
                                        }
                                    }
                                });
                            }

                            

                            //绑定仓房信息
                            if ($(".Store_AutoComplete").length) {

                                $(".Store_AutoComplete").next("input").val("");
                                $(".Store_AutoComplete").find("option").remove();
                                $.ajax({
                                    type: "Get",
                                    url: "../../Data/AutoComplete.ashx",
                                    data: "Function=GetStoreByGranaryID&GranaryID=" + $("#hdGranary").val() + "",
                                    success: function (storeInfo) {
                                        //alert(storeInfo);
                                        $(".Store_AutoComplete").append(storeInfo);
                                        $(".Store_AutoComplete").combobox();
                                    }
                                });
                            }
                        }
                    });
                }
            } //非页面跳转处理流程
            else {
                if (UserTypeId != "YHLX0104" && UserTypeId != "YHLX0105" && UserTypeId != "YHLX0106")                                    //非粮库用户登录
                {
                    $(".Company_AutoComplete").find("option").remove();
                    var CompanyOptionInfo = "";
                    if (isCompanyCheckAll == "true") {
                        CompanyOptionInfo = "<option value=\"QuanBu\" title=\"QuanBu\">--全部--</option>" + companyInfo;
                    }
                    else {
                        CompanyOptionInfo = companyInfo;
                    }
                    $(".Company_AutoComplete").append(CompanyOptionInfo);
                    //调用AutoComplete
                    $(".Company_AutoComplete").combobox();

                    if (isCompanyCheckAll == "true") {
                        if ($("#hdCompany").val() == "" || $("#hdCompany").val() == "QuanBu") {
                            //分公司选项，选中“全部”
                            $(".Company_AutoComplete").next("input").val($(".Company_AutoComplete").find("option").eq(0).text());
                            $("#hdCompany").val($(".Company_AutoComplete").find("option").eq(0).val());
                            $("#hdGompanyName").val($(".Granary_AutoComplete").find("option").eq(0).text());
                        }
                    }
                    //alert(UserTypeId);
                    if (UserTypeId == "YHLX0101" || UserTypeId == "YHLX0102") //登陆用户为总公司或者系统管理员
                    {
                        $.ajax({
                            type: "Get",
                            url: "../../Data/AutoComplete.ashx",
                            data: "Function=GetGranaryByUserType&CompaneyID=" + CompaneyID + "&CompanyName=" + CompanyName + "&UserTypeId=" + UserTypeId + "&GranaryDcExist=" + granaryDcExist,
                            success: function (granaryInfo) {
                                //alert(granaryInfo);
                                $(".Granary_AutoComplete").next("input").val("");
                                $(".Granary_AutoComplete").find("option").remove();

                                if (isGranaryCheckAll == "true") {
                                    granaryInfo = "<option value=\"QuanBu\" title=\"QuanBu\">--全部--</option>" + granaryInfo;
                                }
                                $(".Granary_AutoComplete").append(granaryInfo);
                                $(".Granary_AutoComplete").combobox();

                                if (isGranaryCheckAll == "true") {
                                    if ($("#hdGranary").val() == "" || $("#hdGranary").val() == "QuanBu") {
                                        $(".Granary_AutoComplete").next("input").val($(".Granary_AutoComplete").find("option").eq(0).text());
                                        $("#hdGranary").val($(".Granary_AutoComplete").find("option").eq(0).val());
                                        $("#hdGranaryName").val($(".Granary_AutoComplete").find("option").eq(0).text());
                                    }
                                }

                                //绑定代储库
                                if ($(".Granary_AutoComplete_DC").length) {
                                    $(".Granary_AutoComplete_DC").next("input").val("");
                                    $(".Granary_AutoComplete_DC").find("option").remove();

                                    $.ajax({
                                        type: "Get",
                                        url: "../../Data/AutoComplete.ashx",
                                        data: "Function=GetSubGranary&GranaryID=" + $("#hdGranary").val() + "&LoginOrgCode=" + CompaneyID + "&LoginOrgName=" + CompanyName + "&IsContainAll=" + IsContainAll + "&IsHaveOil=" + IsHaveOil,
                                        success: function (granaryDCInfo) {

                                            $(".Granary_AutoComplete_DC").append(granaryDCInfo);
                                            $(".Granary_AutoComplete_DC").combobox();

                                            Text = "";
                                            if ($("#hdGranaryDC").val() != "") {
                                                $(".Granary_AutoComplete_DC").find("option").map(function () {
                                                    var value = $(this).val();
                                                    if (value == $("#hdGranaryDC").val()) {
                                                        Text = $(this).text();
                                                        //选项被选中
                                                        //$(this).attr("Selected", "true");
                                                        $("#hdGranaryDC").val(value);
                                                        $("#hdGranaryNameDC").val(Text);
                                                    }
                                                });
                                            }
                                            if (Text == "") {
                                                //自动选择第一个
                                                $("#hdGranaryDC").val($(".Granary_AutoComplete_DC").find("option").eq(1).val());
                                                $("#hdGranaryNameDC").val($(".Granary_AutoComplete_DC").find("option").eq(1).text());
                                                $(".Granary_AutoComplete_DC").next("input").val($(".Granary_AutoComplete_DC").find("option").eq(1).text());
                                            }
                                            else {
                                                $(".Granary_AutoComplete_DC").next("input").val(Text);
                                            }
                                            if ($.isFunction(window.granarydcChange)) {
                                                granarydcChange();
                                            }

                                            //绑定油罐信息
                                            if ($(".OilStore_AutoComplete").length || $("#hdOilStoreInfo").length) {

                                                $.ajax({
                                                    type: "Get",
                                                    cache: false,
                                                    url: "../../Data/AutoComplete.ashx",
                                                    data: "Function=GetOilTankByGranaryID&GranaryID=" + $("#hdGranaryDC").val() + "",
                                                    success: function (storeInfo) {
                                                        $("#hdOilStoreInfo").val();
                                                        $("td .OilTankTd").find("select").find("option").remove();
                                                        $("#hdOilStoreInfo").val(storeInfo);
                                                        $("td .OilTankTd").find("select").append("<option value='-1'>--请选择--</option>");
                                                        $("td .OilTankTd").find("select").append(storeInfo);
                                                        //alert(storeInfo);
                                                        $(".OilStore_AutoComplete").next("input").val("");
                                                        $(".OilStore_AutoComplete").find("option").remove();


                                                        if (isStoreHouseCheckAll == "true" && storeInfo!="") {
                                                            storeInfo = "<option value=\"QuanBu\" title=\"QuanBu\">--全部--</option>" + storeInfo;
                                                        }

                                                        $(".OilStore_AutoComplete").append(storeInfo);
                                                        $(".OilStore_AutoComplete").combobox();

                                                        Text = "";

                                                        $(".OilStore_AutoComplete").find("option").map(function () {
                                                            var value = $(this).val();
                                                            if (value == $("#hdOilStore").val()) {
                                                                Text = $(this).text();
                                                                //选项被选中
                                                                $("#hdOilStore").val(value);
                                                                $("#hdOilStoreName").val(Text);
                                                            }
                                                        });
                                                        if (Text != "") {
                                                            $(".OilStore_AutoComplete").next("input").val(Text);
                                                        }
                                                        else {
                                                            //选中全部
                                                            $("#hdOilStore").val($(".OilStore_AutoComplete").find("option").eq(0).val());
                                                            $("#hdOilStoreName").val($(".OilStore_AutoComplete").find("option").eq(0).text());
                                                            $(".OilStore_AutoComplete").next("input").val($(".OilStore_AutoComplete").find("option").eq(0).text());
                                                        }
                                                    }
                                                });
                                            }
                                        }
                                    });
                                }

                                
                                //绑定仓房信息
                                if ($(".Store_AutoComplete").length) {

                                    $(".Store_AutoComplete").next("input").val("");
                                    $(".Store_AutoComplete").find("option").remove();
                                    $.ajax({
                                        type: "Get",
                                        url: "../../Data/AutoComplete.ashx",
                                        data: "Function=GetStoreByGranaryID&GranaryID=" + $("#hdGranary").val() + "",
                                        success: function (storeInfo) {
                                            //alert(storeInfo);
                                            $(".Store_AutoComplete").append(storeInfo);
                                            $(".Store_AutoComplete").combobox();

                                        }
                                    });
                                }
                                if (typeof ShowTime == "function") {
                                    if ($("#ddl_ShowTime").length) {
                                        ShowTime($("#hdCompany").val(), $("#hdGranary").val(), $("#hdStore1").val());
                                    }
                                }
                                //绑定期数信息
                                if ($(".CheckNum_AutoComplete").length) {

                                    $(".CheckNum_AutoComplete").next("input").val("");
                                    $(".CheckNum_AutoComplete").find("option").remove();
                                    $.ajax({
                                        type: "Get",
                                        url: "../../Data/AutoComplete.ashx",
                                        data: "Function=GetCheckNumByGranaryIDCompanyID&GranaryID=" + $("#hdGranary").val() + "&CompanyID=" + $("#hdCompany").val(),
                                        success: function (checkNumInfo) {
                                            //alert(checkNumInfo);
                                            checkNumInfo = "<option value=\"QuanBu\" title=\"QuanBu\">--全部--</option>" + checkNumInfo;

                                            $(".CheckNum_AutoComplete").next("input").val("");
                                            $(".CheckNum_AutoComplete").find("option").remove();

                                            $(".CheckNum_AutoComplete").append(checkNumInfo);
                                            $(".CheckNum_AutoComplete").combobox();

                                            //自动选择“--全部--”
                                            $("#hdCheckNum").val($(".CheckNum_AutoComplete").find("option").eq(0).val());
                                            $("#hdCheckNumName").val($(".CheckNum_AutoComplete").find("option").eq(0).text());
                                            $(".CheckNum_AutoComplete").next("input").val($(".CheckNum_AutoComplete").find("option").eq(0).text());
                                        }
                                    });
                                }
                                //绑定测控日期(HouseComp.aspx）
                                if ($(".Time_AutoComplete").length) {
                                    $.ajax({
                                        type: "Get",
                                        url: "../../Data/AutoComplete.ashx",
                                        data: "Function=GetTimeByGranaryIDStoreID&StoreID=-1&GranaryID=" + $(".Granary_AutoComplete").find("option").eq(0).val() + "",
                                        success: function (dateInfo) {
                                            //alert(dateInfo);
                                            $(".Time_AutoComplete").next("input").val("");
                                            $(".Time_AutoComplete").find("option").remove();

                                            $(".Time_AutoComplete").append(dateInfo);
                                            $(".Time_AutoComplete").combobox();
                                        }
                                    });
                                }
                            }
                        });
                    }

                    if (UserTypeId == "YHLX0103") {                      //登陆用户为类型为分公司管理员，选中分公司信息
                        var CompanyIDNow = "";
                        if ($("#hdCompany").val() == "") {

                            if (isCompanyCheckAll == "true") {
                                CompanyIDNow == "QuanBu";               //选中“全部”
                            }
                            else {
                                CompanyIDNow = CompaneyID;
                            }
                        }
                        else {
                            CompanyIDNow = $("#hdCompany").val();
                        }
                        var Text = "";

                        $(".Company_AutoComplete").find("option").map(function () {
                            var value = $(this).val();
                            if (value == CompanyIDNow) {
                                Text = $(this).text();
                                //选项被选中
                                //$(this).attr("Selected", "true");
                                $("#hdCompany").val(value);
                                $("#hdCompanyName").val(Text);
                            }
                        })
                        $(".Company_AutoComplete").next("input").val(Text);

                        //绑定粮库信息
                        $.ajax({
                            type: "Get",
                            url: "../../Data/AutoComplete.ashx",
                            data: "Function=GetGranaryByUserType&CompaneyID=" + CompanyIDNow + "&CompanyName=" + CompanyName + "&UserTypeId=" + UserTypeId + "&GranaryDcExist=" + granaryDcExist,
                            success: function (granaryInfo) {
                                //alert(granaryInfo);
                                $(".Granary_AutoComplete").find("option").remove();

                                if (isGranaryCheckAll == "true") {
                                    granaryInfo = "<option value=\"QuanBu\" title=\"QuanBu\">--全部--</option>" + granaryInfo;
                                }

                                $(".Granary_AutoComplete").append(granaryInfo);

                                $(".Granary_AutoComplete").combobox();
                                //自动选择粮库 
                                //$(".Granary_AutoComplete").next("input").val($(".Granary_AutoComplete").find("option").eq(1).attr("selected", "true").text());
                                if (isGranaryCheckAll == "true") {
                                    if ($("#hdGranary").val() == "" || $("#hdGranary").val() == "QuanBu") {
                                        $(".Granary_AutoComplete").next("input").val($(".Granary_AutoComplete").find("option").eq(0).text());
                                        $("#hdGranary").val($(".Granary_AutoComplete").find("option").eq(0).val());
                                        $("#hdGranaryName").val($(".Granary_AutoComplete").find("option").eq(0).text());
                                    }
                                }
                                else {
                                    if ($("#hdGranary").val() == "") {
                                        $("#hdGranary").val($(".Granary_AutoComplete").find("option").eq(1).val());
                                        $("#hdGranaryName").val($(".Granary_AutoComplete").find("option").eq(1).text());
                                        $(".Granary_AutoComplete").next("input").val($(".Granary_AutoComplete").find("option").eq(1).text());
                                    }
                                }


                                //绑定代储库
                                if ($(".Granary_AutoComplete_DC").length) {
                                    $(".Granary_AutoComplete_DC").next("input").val("");
                                    $(".Granary_AutoComplete_DC").find("option").remove();

                                    $.ajax({
                                        type: "Get",
                                        url: "../../Data/AutoComplete.ashx",
                                        data: "Function=GetSubGranary&GranaryID=" + $("#hdGranary").val() + "&LoginOrgCode=" + CompaneyID + "&LoginOrgName=" + CompanyName + "&IsContainAll=" + IsContainAll + "&IsHaveOil=" + IsHaveOil,
                                        success: function (granaryDCInfo) {
                                            //alert(granaryDCInfo);
                                            $(".Granary_AutoComplete_DC").append(granaryDCInfo);
                                            $(".Granary_AutoComplete_DC").combobox();

                                            Text = "";
                                            var granaryDCVal = $("#hdGranaryDC").val();
                                            //alert(granaryDCVal);
                                            if (granaryDCVal == "") {
                                                granaryDCVal = $("#hdGranary").val();
                                            }

                                            $(".Granary_AutoComplete_DC").find("option").map(function () {
                                                var value = $(this).val();
                                                if (value == granaryDCVal) {
                                                    Text = $(this).text();
                                                    //选项被选中
                                                    //$(this).attr("Selected", "true");
                                                    $("#hdGranaryDC").val(value);
                                                    $("#hdGranaryNameDC").val(Text);
                                                }
                                            });
                                            if ($.isFunction(window.granarydcChange)) {
                                                granarydcChange();
                                            }
                                            $(".Granary_AutoComplete_DC").next("input").val(Text);

                                            //绑定油罐信息
                                            if ($(".OilStore_AutoComplete").length || $("#hdOilStoreInfo").length) {
                                                $.ajax({
                                                    type: "Get",
                                                    cache: false,
                                                    url: "../../Data/AutoComplete.ashx",
                                                    data: "Function=GetOilTankByGranaryID&GranaryID=" + $("#hdGranaryDC").val() + "",
                                                    success: function (storeInfo) {
                                                        $("#hdOilStoreInfo").val();
                                                        $("td .OilTankTd").find("select").find("option").remove();
                                                        $("#hdOilStoreInfo").val(storeInfo);
                                                        $("td .OilTankTd").find("select").append("<option value='-1'>--请选择--</option>");
                                                        $("td .OilTankTd").find("select").append(storeInfo);
                                                        //alert(storeInfo);
                                                        $(".OilStore_AutoComplete").next("input").val("");
                                                        $(".OilStore_AutoComplete").find("option").remove();


                                                        if (isStoreHouseCheckAll == "true" && storeInfo != "") {
                                                            storeInfo = "<option value=\"QuanBu\" title=\"QuanBu\">--全部--</option>" + storeInfo;
                                                        }

                                                        $(".OilStore_AutoComplete").append(storeInfo);
                                                        $(".OilStore_AutoComplete").combobox();

                                                        Text = "";

                                                        $(".OilStore_AutoComplete").find("option").map(function () {
                                                            var value = $(this).val();
                                                            if (value == $("#hdOilStore").val()) {
                                                                Text = $(this).text();
                                                                //选项被选中
                                                                $("#hdOilStore").val(value);
                                                                $("#hdOilStoreName").val(Text);
                                                            }
                                                        });

                                                        if (Text != "") {
                                                            $(".OilStore_AutoComplete").next("input").val(Text);
                                                        }
                                                        else {
                                                            //选中全部
                                                            $("#hdOilStore").val($(".OilStore_AutoComplete").find("option").eq(0).val());
                                                            $("#hdOilStoreName").val($(".OilStore_AutoComplete").find("option").eq(0).text());
                                                            $(".OilStore_AutoComplete").next("input").val($(".OilStore_AutoComplete").find("option").eq(0).text());
                                                        }
                                                    }
                                                });
                                            }
                                        }
                                    });
                                }

                                

                                //绑定仓房信息
                                if ($(".Store_AutoComplete").length) {

                                    $(".Store_AutoComplete").next("input").val("");
                                    $(".Store_AutoComplete").find("option").remove();
                                    $.ajax({
                                        type: "Get",
                                        url: "../../Data/AutoComplete.ashx",
                                        //data: "Function=GetStoreByGranaryID&GranaryID=" + $(".Granary_AutoComplete").find("option").eq(1).val() + "",
                                        data: "Function=GetStoreByGranaryID&GranaryID=" + $("#hdGranary").val() + "",
                                        success: function (storeInfo) {
                                            //alert(storeInfo);

                                            if (isStoreHouseCheckAll == "true") {
                                                storeInfo = "<option value=\"QuanBu\" title=\"QuanBu\">--全部--</option>" + storeInfo;
                                            }

                                            $(".Store_AutoComplete").append(storeInfo);
                                            $(".Store_AutoComplete").combobox();

                                            if (isStoreHouseCheckAll == "true") {
                                                if ($("#hdStore1").val() == "" || $("#hdStore1").val() == "QuanBu") {
                                                    $(".Store_AutoComplete").next("input").val($(".Store_AutoComplete").find("option").eq(0).text());
                                                    $("#hdStore1").val($(".Store_AutoComplete").find("option").eq(0).val());
                                                    $("#hdStoreName1").val($(".Granary_AutoComplete").find("option").eq(0).text());
                                                }
                                            }
                                        }
                                    });
                                }
                                if (typeof ShowTime == "function") {
                                    if ($("#ddl_ShowTime").length) {
                                        ShowTime($("#hdCompany").val(), $("#hdGranary").val(), $("#hdStore1").val());
                                    }
                                }
                                //绑定期数信息
                                if ($(".CheckNum_AutoComplete").length) {
                                    $(".CheckNum_AutoComplete").next("input").val("");
                                    $(".CheckNum_AutoComplete").find("option").remove();
                                    $.ajax({
                                        type: "Get",
                                        url: "../../Data/AutoComplete.ashx",
                                        data: "Function=GetCheckNumByGranaryIDCompanyID&GranaryID=" + $("#hdGranary").val() + "&CompanyID=" + CompaneyID,
                                        success: function (checkNumInfo) {
                                            //alert(checkNumInfo);
                                            checkNumInfo = "<option value=\"QuanBu\" title=\"QuanBu\">--全部--</option>" + checkNumInfo;

                                            $(".CheckNum_AutoComplete").next("input").val("");
                                            $(".CheckNum_AutoComplete").find("option").remove();

                                            $(".CheckNum_AutoComplete").append(checkNumInfo);
                                            $(".CheckNum_AutoComplete").combobox();
                                            //自动选择“--全部--”
                                            $("#hdCheckNum").val($(".CheckNum_AutoComplete").find("option").eq(0).val());
                                            $("#hdCheckNumName").val($(".CheckNum_AutoComplete").find("option").eq(0).text());
                                            $(".CheckNum_AutoComplete").next("input").val($(".CheckNum_AutoComplete").find("option").eq(0).text());
                                        }
                                    });
                                }
                                //绑定测控日期
                                if ($(".Time_AutoComplete").length) {
                                    $.ajax({
                                        type: "Get",
                                        url: "../../Data/AutoComplete.ashx",
                                        data: "Function=GetTimeByGranaryIDStoreID&StoreID=-1&GranaryID=" + $(".Granary_AutoComplete").find("option").eq(1).val() + "",
                                        success: function (dateInfo) {
                                            //alert(dateInfo);
                                            $(".Time_AutoComplete").next("input").val("");
                                            $(".Time_AutoComplete").find("option").remove();

                                            $(".Time_AutoComplete").append(dateInfo);
                                            $(".Time_AutoComplete").combobox();
                                        }
                                    });
                                }
                            }
                        });
                    }
                }
                if (UserTypeId == "YHLX0104" || UserTypeId == "YHLX0105" || UserTypeId == "YHLX0106")          //粮库登陆
                {
                    $(".Company_AutoComplete").find("option").remove();
                    $(".Company_AutoComplete").append(companyInfo);
                    //调用AutoComplete
                    $(".Company_AutoComplete").combobox();

                    //自动选择分公司

                    $("#hdCompany").val($(".Company_AutoComplete").find("option").eq(1).val());
                    $("#hdCompanyName").val($(".Company_AutoComplete").find("option").eq(1).text());
                    $(".Company_AutoComplete").next("input").val($(".Company_AutoComplete").find("option").eq(1).text());

                    $.ajax({
                        type: "Get",
                        url: "../../Data/AutoComplete.ashx",
                        data: "Function=GetGranaryByUserType&CompaneyID=" + CompaneyID + "&CompanyName=" + CompanyName + "&UserTypeId=" + UserTypeId + "&GranaryDcExist=" + granaryDcExist,
                        success: function (granaryInfo) {
                            //alert(granaryInfo);
                            $(".Granary_AutoComplete").find("option").remove();
                            $(".Granary_AutoComplete").append(granaryInfo);
                            $(".Granary_AutoComplete").combobox();
                            //判断是否已选择了粮库
                            var checkGranaryID = "";
                            if ($("#hdGranary").val() != "") {
                                checkGranaryID = $("#hdGranary").val();
                            }

                            if (checkGranaryID == "" || checkGranaryID == null) {
                                //自动选择第一个
                                //$(".Granary_AutoComplete").find("option").eq(1).attr("Selected", "true");
                                $("#hdGranary").val($(".Granary_AutoComplete").find("option").eq(1).val());
                                $("#hdGranaryName").val($(".Granary_AutoComplete").find("option").eq(1).text());
                                $(".Granary_AutoComplete").next("input").val($(".Granary_AutoComplete").find("option").eq(1).text());
                            }


                            //绑定代储库
                            if ($(".Granary_AutoComplete_DC").length) {
                                $(".Granary_AutoComplete_DC").next("input").val("");
                                $(".Granary_AutoComplete_DC").find("option").remove();

                                $.ajax({
                                    type: "Get",
                                    url: "../../Data/AutoComplete.ashx",
                                    data: "Function=GetSubGranary&GranaryID=" + $("#hdGranary").val() + "&LoginOrgCode=" + CompaneyID + "&LoginOrgName=" + CompanyName + "&IsContainAll=" + IsContainAll + "&IsHaveOil=" + IsHaveOil,
                                    success: function (granaryDCInfo) {

                                        $(".Granary_AutoComplete_DC").append(granaryDCInfo);
                                        $(".Granary_AutoComplete_DC").combobox();

                                        Text = "";
                                        var granaryDCVal = $("#hdGranaryDC").val();

                                        if (granaryDCVal == "") {
                                            granaryDCVal = $("#hdGranary").val();
                                        }



                                        $(".Granary_AutoComplete_DC").find("option").map(function () {
                                            var value = $(this).val();
                                            if (value == granaryDCVal) {
                                                Text = $(this).text();
                                                //选项被选中
                                                //$(this).attr("Selected", "true");
                                                $("#hdGranaryDC").val(value);
                                                $("#hdGranaryNameDC").val(Text);
                                            }
                                        });

                                        if (Text == "") {
                                            $("#hdGranaryDC").val($(".Granary_AutoComplete_DC").find("option").eq(1).val());
                                            $("#hdGranaryDCName").val($(".Granary_AutoComplete_DC").find("option").eq(1).text());
                                            $(".Granary_AutoComplete_DC").next("input").val($(".Granary_AutoComplete_DC").find("option").eq(1).text());
                                        }
                                        else {
                                            $(".Granary_AutoComplete_DC").next("input").val(Text);
                                        }
                                        if ($.isFunction(window.granarydcChange)) {
                                            granarydcChange();
                                        }

                                        //绑定油罐信息
                                        if ($(".OilStore_AutoComplete").length || $("#hdOilStoreInfo").length) {

                                            $(".OilStore_AutoComplete").next("input").val("");
                                            $(".OilStore_AutoComplete").find("option").remove();

                                            $.ajax({
                                                type: "Get",
                                                cache: false,
                                                url: "../../Data/AutoComplete.ashx",
                                                data: "Function=GetOilTankByGranaryID&GranaryID=" + $("#hdGranaryDC").val() + "",
                                                success: function (storeInfo) {
                                                    $("#hdOilStoreInfo").val();
                                                    $("td .OilTankTd").find("select").find("option").remove();
                                                    $("#hdOilStoreInfo").val(storeInfo);
                                                    $("td .OilTankTd").find("select").append("<option value='-1'>--请选择--</option>");
                                                    $("td .OilTankTd").find("select").append(storeInfo);
                                                    //alert(storeInfo);
                                                    if (isStoreHouseCheckAll == "true" && storeInfo != "") {
                                                        storeInfo = "<option value=\"QuanBu\" title=\"QuanBu\">--全部--</option>" + storeInfo;
                                                    }

                                                    $(".OilStore_AutoComplete").append(storeInfo);
                                                    $(".OilStore_AutoComplete").combobox();

                                                    Text = "";

                                                    $(".OilStore_AutoComplete").find("option").map(function () {
                                                        var value = $(this).val();
                                                        if (value == $("#hdOilStore").val()) {
                                                            Text = $(this).text();
                                                            //选项被选中
                                                            $("#hdOilStore").val(value);
                                                            $("#hdOilStoreName").val(Text);
                                                        }
                                                    });

                                                    if (Text != "") {

                                                        $(".OilStore_AutoComplete").next("input").val(Text);
                                                    }
                                                    else {
                                                        //选中全部
                                                        $("#hdOilStore").val($(".OilStore_AutoComplete").find("option").eq(0).val());
                                                        $("#hdOilStoreName").val($(".OilStore_AutoComplete").find("option").eq(0).text());
                                                        $(".OilStore_AutoComplete").next("input").val($(".OilStore_AutoComplete").find("option").eq(0).text());
                                                    }
                                                }
                                            });
                                        }
                                    }
                                });
                            }

                         
                            //绑定仓房信息
                            if ($(".Store_AutoComplete").length) {

                                $(".Store_AutoComplete").next("input").val("");
                                $(".Store_AutoComplete").find("option").remove();
                                $.ajax({
                                    type: "Get",
                                    url: "../../Data/AutoComplete.ashx",
                                    data: "Function=GetStoreByGranaryID&GranaryID=" + $("#hdGranary").val() + "",
                                    success: function (storeInfo) {

                                        if (isStoreHouseCheckAll == "true") {
                                            storeInfo = "<option value=\"QuanBu\" title=\"QuanBu\">--全部--</option>" + storeInfo;
                                        }

                                        //alert(storeInfo);
                                        $(".Store_AutoComplete").append(storeInfo);
                                        $(".Store_AutoComplete").combobox();

                                        if (isStoreHouseCheckAll == "true") {
                                            if ($("#hdStore1").val() == "" || $("#hdStore1").val() == "QuanBu") {
                                                $(".Store_AutoComplete").next("input").val($(".Store_AutoComplete").find("option").eq(0).text());
                                                $("#hdStore1").val($(".Store_AutoComplete").find("option").eq(0).val());
                                                $("#hdStoreName1").val($(".Granary_AutoComplete").find("option").eq(0).text());
                                            }
                                        }
                                    }
                                });
                            }
                            if (typeof ShowTime == "function") {
                                if ($("#ddl_ShowTime").length) {
                                    ShowTime($("#hdCompany").val(), $("#hdGranary").val(), $("#hdStore1").val());
                                }
                            }
                            //绑定期数信息
                            if ($(".CheckNum_AutoComplete").length) {
                                $(".CheckNum_AutoComplete").next("input").val("");
                                $(".CheckNum_AutoComplete").find("option").remove();
                                $.ajax({
                                    type: "Get",
                                    url: "../../Data/AutoComplete.ashx",
                                    data: "Function=GetCheckNumByGranaryIDCompanyID&GranaryID=" + $("#hdGranary").val() + "&CompanyID=" + $("#hdCompany").val(),
                                    success: function (checkNumInfo) {
                                        //alert(checkNumInfo);
                                        checkNumInfo = "<option value=\"QuanBu\" title=\"QuanBu\">--全部--</option>" + checkNumInfo;

                                        $(".CheckNum_AutoComplete").next("input").val("");
                                        $(".CheckNum_AutoComplete").find("option").remove();

                                        $(".CheckNum_AutoComplete").append(checkNumInfo);
                                        $(".CheckNum_AutoComplete").combobox();

                                        //自动选择“--全部--”
                                        $("#hdCheckNum").val($(".CheckNum_AutoComplete").find("option").eq(0).val());
                                        $("#hdCheckNumName").val($(".CheckNum_AutoComplete").find("option").eq(0).text());
                                        $(".CheckNum_AutoComplete").next("input").val($(".CheckNum_AutoComplete").find("option").eq(0).text());
                                    }
                                });
                            }

                            //绑定测控日期
                            if ($(".Time_AutoComplete").length) {
                                $.ajax({
                                    type: "Get",
                                    url: "../../Data/AutoComplete.ashx",
                                    data: "Function=GetTimeByGranaryIDStoreID&StoreID=-1&GranaryID=" + $("#hdGranary").val() + "",
                                    success: function (dateInfo) {
                                        //alert(dateInfo);
                                        $(".Time_AutoComplete").next("input").val("");
                                        $(".Time_AutoComplete").find("option").remove();

                                        $(".Time_AutoComplete").append(dateInfo);
                                        $(".Time_AutoComplete").combobox();
                                    }
                                });
                            }
                        }
                    });
                }
            }
            //显示已选信息

            

            //判断是否已经选过分公司
            var CompanyID = $("#hdCompany").val();
            //alert(CompanyID);
            var Text = "";
            //alert($("#hdCompany").val());
            if (CompanyID != "") {
                //首先选中此项
                $(".Company_AutoComplete").find("option").map(function () {
                    var value = $(this).val();
                    if (value == CompanyID) {
                        Text = $(this).text();
                        //选项被选中
                        //$(this).attr("Selected", "true");
                        $("#hdCompany").val(value);
                        $("#hdCompanyName").val(Text);
                    }
                });
                $(".Company_AutoComplete").next("input").val(Text);
                //判断用户类型，绑定粮库信息
                if (UserTypeId == "YHLX0104" || UserTypeId == "YHLX0105" || UserTypeId == "YHLX0106") {

                    $.ajax({
                        type: "Get",
                        url: "../../Data/AutoComplete.ashx",
                        data: "Function=GetGranaryByUserType&CompaneyID=" + CompaneyID + "&CompanyName=" + CompanyName + "&UserTypeId=" + UserTypeId + "&GranaryDcExist=" + granaryDcExist,
                        success: function (granaryInfo) {
                            //alert(granaryInfo);
                            $(".Granary_AutoComplete").find("option").remove();
                            $(".Granary_AutoComplete").append(granaryInfo);

                            //判断是否已经选过粮库
                            var GranaryID = $("#hdGranary").val();
                            //alert(GranaryID);
                            if ((GranaryID == "" || GranaryID == null) && Gid != "") {
                                GranaryID = Gid;
                            }
                            if (GranaryID != "") {
                                //选中并显示
                                Text = "";
                                $(".Granary_AutoComplete").find("option").map(function () {
                                    var value = $(this).val();
                                    if (value == GranaryID) {
                                        Text = $(this).text();
                                        //选项被选中
                                        //$(this).attr("Selected", "true");
                                        $("#hdGranary").val(value);
                                        $("#hdGranaryName").val(Text);
                                    }
                                });
                                $(".Granary_AutoComplete").next("input").val(Text);
                            };

                            //判断是否已选择过代储库
                            var GranaryIDDC = $("#hdGranaryDC").val();

                            //alert(GranaryIDDC);
                            if (GranaryIDDC != "") {
                                $.ajax({
                                    type: "Get",
                                    url: "../../Data/AutoComplete.ashx",
                                    data: "Function=GetSubGranary&GranaryID=" + $("#hdGranary").val() + "&LoginOrgCode=" + CompaneyID + "&LoginOrgName" + CompanyName + "&IsContainAll=" + IsContainAll + "&IsHaveOil=" + IsHaveOil,
                                    success: function (granaryDCInfo) {
                                        //                                        alert($("#hdGranary").val());
                                        //                                        alert(granaryDCInfo);
                                        $(".Granary_AutoComplete_DC").find("option").remove();
                                        $(".Granary_AutoComplete_DC").append(granaryDCInfo);

                                        //选中并显示
                                        Text = "";
                                        $(".Granary_AutoComplete_DC").find("option").map(function () {
                                            var value = $(this).val();
                                            if (value == GranaryIDDC) {
                                                Text = $(this).text();
                                                //选项被选中
                                                //$(this).attr("Selected", "true");
                                                $("#hdGranaryDC").val(value);
                                                $("#hdGranaryNameDC").val(Text);
                                            }
                                        });
                                        $(".Granary_AutoComplete_DC").next("input").val(Text);
                                        if ($.isFunction(window.granarydcChange)) {
                                            granarydcChange();
                                        }
                                    }
                                });
                            };

                            //判断是否已选过时间信息
                            var TimeID = $("#hdTime1").val();

                            if (TimeID != "") {
                                $("#ddl_Time_AutoComplete1").next("input").val("");
                                $("#ddl_Time_AutoComplete1").find("option").remove();

                                $.ajax({
                                    type: "Get",
                                    url: "../../Data/AutoComplete.ashx",
                                    data: "Function=GetTimeByGranaryIDStoreID&StoreID=-1&GranaryID=" + GranaryID + "",
                                    success: function (timeInfo) {
                                        //alert(timeInfo);
                                        $("#ddl_Time_AutoComplete1").append(timeInfo);

                                        //选中并显示
                                        Text = "";
                                        $("#ddl_Time_AutoComplete").find("option").map(function () {
                                            var value = $(this).val();
                                            if (value == TimeID) {
                                                Text = $(this).text();
                                                //选项被选中
                                                //$(this).attr("Selected", "true");
                                                $("#hdTime1").val(value);
                                                $("#hdTimeValue1").val(Text);
                                            }
                                        });
                                        $("#ddl_Time_AutoComplete1").next("input").val(Text);
                                    }
                                });
                            }

                            //判断是否选择期数信息
                            var CheckNum = $("#hdCheckNum").val();
                            if (CheckNum != "") {
                                if ($(".CheckNum_AutoComplete").length) {
                                    $.ajax({
                                        type: "Get",
                                        url: "../../Data/AutoComplete.ashx",
                                        data: "Function=GetCheckNumByGranaryIDCompanyID&GranaryID=" + GranaryID + "&CompanyID=" + CompanyID,
                                        success: function (checkNumInfo) {
                                            //alert(checkNumInfo);
                                            $(".CheckNum_AutoComplete").next("input").val("");
                                            $(".CheckNum_AutoComplete").find("option").remove();

                                            checkNumInfo = "<option value=\"QuanBu\" title=\"QuanBu\">--全部--</option>" + checkNumInfo;

                                            $(".CheckNum_AutoComplete").append(checkNumInfo);
                                            //选中并显示
                                            Text = "";
                                            $(".CheckNum_AutoComplete").find("option").map(function () {
                                                var value = $(this).val();
                                                if (value == CheckNum) {
                                                    Text = $(this).text();
                                                    //选项被选中
                                                    //$(this).attr("Selected", "true");
                                                    $("#hdCheckNum").val(value);
                                                    $("#hdCheckNumName").val(Text);
                                                }
                                            })
                                            $(".CheckNum_AutoComplete").next("input").val(Text);
                                        }
                                    });
                                }
                            }

                            //判断是否已选过仓房信息
                            var Storelength = $(".Store_AutoComplete").length;
                            //alert(Storelength);
                            for (var i = 0; i < Storelength; i++) {
                                if (i == 0) {
                                    var StoreID1 = $("#hdStore1").val();
                                    if (StoreID1 != "") {
                                        $.ajax({
                                            type: "Get",
                                            url: "../../Data/AutoComplete.ashx",
                                            data: "Function=GetStoreByGranaryID&GranaryID=" + GranaryID + "",
                                            success: function (storeInfo) {
                                                //alert(storeInfo);
                                                $("#ddl_Store_AutoComplete1").next("input").val("");
                                                $("#ddl_Store_AutoComplete1").find("option").remove();

                                                if (isStoreHouseCheckAll == "true") {
                                                    storeInfo = "<option value=\"QuanBu\" title=\"QuanBu\">--全部--</option>" + storeInfo;
                                                }

                                                $("#ddl_Store_AutoComplete1").append(storeInfo);
                                                $(".Store_AutoComplete").combobox();

                                                //选中并显示
                                                Text = "";
                                                $("#ddl_Store_AutoComplete1").find("option").map(function () {
                                                    var value = $(this).val();
                                                    if (value == StoreID1) {
                                                        Text = $(this).text();
                                                        //选项被选中
                                                        //$(this).attr("Selected", "true");
                                                        $("#hdStore1").val(value);
                                                        $("#hdStoreName1").val(Text);
                                                    }
                                                });
                                                $("#ddl_Store_AutoComplete1").next("input").val(Text);
                                                //判断是否已选过时间信息
                                                var TimeID1 = $("#hdTime1").val();

                                                if (TimeID1 != "") {
                                                    $("#ddl_Time_AutoComplete1").next("input").val("");
                                                    $("#ddl_Time_AutoComplete1").find("option").remove();

                                                    $.ajax({
                                                        type: "Get",
                                                        url: "../../Data/AutoComplete.ashx",
                                                        data: "Function=GetTimeByGranaryIDStoreID&StoreID=" + StoreID1 + "&GranaryID=" + GranaryID + "",
                                                        success: function (timeInfo) {
                                                            //alert(timeInfo);
                                                            $("#ddl_Time_AutoComplete1").append(timeInfo);
                                                            $(".Time_AutoComplete").combobox();
                                                            //选中并显示
                                                            Text = "";
                                                            $("#ddl_Time_AutoComplete1").find("option").map(function () {
                                                                var value = $(this).val();
                                                                if (value == TimeID1) {
                                                                    Text = $(this).text();
                                                                    //选项被选中
                                                                    //$(this).attr("Selected", "true");
                                                                    $("#hdTime1").val(value);
                                                                    $("#hdTimeValue1").val(value);
                                                                }
                                                            });
                                                            $("#ddl_Time_AutoComplete1").next("input").val(Text);
                                                        }
                                                    });
                                                }
                                            }
                                        });
                                    }
                                }
                                if (i == 1) {
                                    //alert("1111")
                                    var StoreID2 = $("#hdStore2").val();

                                    if (StoreID2 != "") {
                                        $.ajax({
                                            type: "Get",
                                            url: "../../Data/AutoComplete.ashx",
                                            data: "Function=GetStoreByGranaryID&GranaryID=" + GranaryID + "",
                                            success: function (storeInfo) {
                                                $("#ddl_Store_AutoComplete2").next("input").val("");
                                                $("#ddl_Store_AutoComplete2").find("option").remove();

                                                if (isStoreHouseCheckAll == "true") {
                                                    storeInfo = "<option value=\"QuanBu\" title=\"QuanBu\">--全部--</option>" + storeInfo;
                                                }

                                                $("#ddl_Store_AutoComplete2").append(storeInfo);
                                                $(".Store_AutoComplete").combobox();
                                                //选中并显示
                                                Text = "";
                                                $("#ddl_Store_AutoComplete2").find("option").map(function () {
                                                    var value = $(this).val();
                                                    if (value == StoreID2) {
                                                        Text = $(this).text();
                                                        //选项被选中
                                                        //$(this).attr("Selected", "true");
                                                        $("#hdStore2").val(value);
                                                        $("#hdStoreName2").val(Text);
                                                    }
                                                });
                                                $("#ddl_Store_AutoComplete2").next("input").val(Text);
                                                //判断是否已选过时间信息
                                                var TimeID2 = $("#hdTime2").val();

                                                if (TimeID2 != "") {
                                                    $("#ddl_Time_AutoComplete2").next("input").val("");
                                                    $("#ddl_Time_AutoComplete2").find("option").remove();

                                                    $.ajax({
                                                        type: "Get",
                                                        url: "../../Data/AutoComplete.ashx",
                                                        data: "Function=GetTimeByGranaryIDStoreID&StoreID=" + StoreID2 + "&GranaryID=" + GranaryID + "",
                                                        success: function (timeInfo) {
                                                            //alert(timeInfo);
                                                            $("#ddl_Time_AutoComplete2").append(timeInfo);
                                                            $(".Time_AutoComplete").combobox();
                                                            //选中并显示
                                                            Text = "";
                                                            $("#ddl_Time_AutoComplete2").find("option").map(function () {
                                                                var value = $(this).val();
                                                                if (value == TimeID2) {
                                                                    Text = $(this).text();
                                                                    //选项被选中
                                                                    //$(this).attr("Selected", "true");
                                                                    $("#hdTime2").val(value);
                                                                    $("#hdTimeValue2").val(Text);
                                                                }
                                                            });
                                                            $("#ddl_Time_AutoComplete2").next("input").val(Text);
                                                        }
                                                    });
                                                }
                                            }
                                        });
                                    }
                                }
                            }
                        }
                    });
                }
                else {
                    //判断是否已经选过粮库
                    var GranaryID = $("#hdGranary").val();
                    if ((GranaryID == "" || GranaryID == null) && Gid != "") {
                        GranaryID = Gid;
                    }
                    $.ajax({
                        type: "Get",
                        url: "../../Data/AutoComplete.ashx",
                        data: "Function=GetGranaryByUserType&CompaneyID=" + CompanyID + "&CompanyName=" + CompanyName + "&UserTypeId=" + UserTypeId + "&GranaryDcExist=" + granaryDcExist,
                        success: function (granaryInfo) {
                            //alert(granaryInfo);
                            $(".Granary_AutoComplete").next("input").val("");
                            $(".Granary_AutoComplete").find("option").remove();

                            if (isGranaryCheckAll == "true") {
                                granaryInfo = "<option value=\"QuanBu\" title=\"QuanBu\">--全部--</option>" + granaryInfo;
                            }

                            $(".Granary_AutoComplete").append(granaryInfo);

                            if (GranaryID != "") {
                                //选中并显示
                                Text = "";
                                $(".Granary_AutoComplete").find("option").map(function () {
                                    var value = $(this).val();
                                    if (value == GranaryID) {
                                        Text = $(this).text();
                                        //选项被选中
                                        // $(this).attr("Selected", "true");           //IE6 对于动态加载的option存在选择bug，跳过此步骤，直接给隐藏控件赋值
                                        $("#hdGranary").val(value);
                                        $("#hdGranaryName").val(Text);
                                    }
                                });
                                $(".Granary_AutoComplete").next("input").val(Text);

                                //                                //判断是否已选择过代储库
                                //                                var GranaryIDDC = $("#hdGranaryDC").val();
                                //                                // alert($("#hdGranary").val());
                                //                                // alert(GranaryIDDC);
                                //                                if (GranaryIDDC != "") {

                                //                                    $(".Granary_AutoComplete_DC").next("input").val("");
                                //                                    $(".Granary_AutoComplete_DC").find("option").remove();
                                //                                    //alert($(".Granary_AutoComplete_DC").find("option").length);
                                //                                    $.ajax({
                                //                                        type: "Get",
                                //                                        url: "../../Data/AutoComplete.ashx",
                                //                                        data: "Function=GetSubGranary&GranaryID=" + $("#hdGranary").val() + "&LoginOrgCode=" + CompaneyID + "&LoginOrgName" + CompanyName + "&IsContainAll=" + IsContainAll,
                                //                                        success: function (granaryDCInfo) {
                                //                                            //alert(granaryDCInfo);
                                //                                            $(".Granary_AutoComplete_DC").append(granaryDCInfo);

                                //                                            //选中并显示
                                //                                            Text = "";
                                //                                            $(".Granary_AutoComplete_DC").find("option").map(function () {
                                //                                                var value = $(this).val();
                                //                                                if (value == GranaryIDDC) {
                                //                                                    Text = $(this).text();
                                //                                                    //选项被选中
                                //                                                    //$(this).attr("Selected", "true");
                                //                                                    $("#hdGranaryDC").val(value);
                                //                                                    $("#hdGranaryNameDC").val(Text);
                                //                                                }
                                //                                            });
                                //                                            $(".Granary_AutoComplete_DC").next("input").val(Text);
                                //                                        }
                                //                                    });
                                //                                };

                                //判断是否已选过时间信息
                                var TimeID = $("#hdTime1").val();
                                //alert(TimeID);
                                if (TimeID != "") {
                                    $.ajax({
                                        type: "Get",
                                        url: "../../Data/AutoComplete.ashx",
                                        data: "Function=GetTimeByGranaryIDStoreID&StoreID=-1&GranaryID=" + GranaryID + "",
                                        success: function (timeInfo) {
                                            //alert(timeInfo);
                                            $("#ddl_Time_AutoComplete1").next("input").val("");
                                            $("#ddl_Time_AutoComplete1").find("option").remove();
                                            $("#ddl_Time_AutoComplete1").append(timeInfo);
                                            $(".Time_AutoComplete").combobox();
                                            //选中并显示
                                            Text = "";
                                            $("#ddl_Time_AutoComplete1").find("option").map(function () {
                                                var value = $(this).val();
                                                if (value == TimeID) {
                                                    Text = $(this).text();
                                                    //选项被选中
                                                    //$(this).attr("Selected", "true");
                                                    $("#hdTime1").val(value);
                                                    $("#hdTimeValue1").val(Text);
                                                }
                                            });
                                            $("#ddl_Time_AutoComplete1").next("input").val(Text);
                                        }
                                    });
                                }
                                //判断是否选择期数信息
                                var CheckNum = $("#hdCheckNum").val();

                                if (CheckNum != "") {
                                    if ($(".CheckNum_AutoComplete").length) {
                                        $.ajax({
                                            type: "Get",
                                            url: "../../Data/AutoComplete.ashx",
                                            data: "Function=GetCheckNumByGranaryIDCompanyID&GranaryID=" + GranaryID + "&CompanyID=" + CompanyID,
                                            success: function (checkNumInfo) {

                                                $(".CheckNum_AutoComplete").next("input").val("");
                                                $(".CheckNum_AutoComplete").find("option").remove();

                                                checkNumInfo = "<option value=\"QuanBu\" title=\"QuanBu\">--全部--</option>" + checkNumInfo;

                                                //alert(checkNumInfo);
                                                $(".CheckNum_AutoComplete").append(checkNumInfo);
                                                $(".CheckNum_AutoComplete").combobox();
                                                //选中并显示
                                                Text = "";
                                                $(".CheckNum_AutoComplete").find("option").map(function () {
                                                    var value = $(this).val();
                                                    if (value == CheckNum) {
                                                        Text = $(this).text();
                                                        //选项被选中
                                                        //$(this).attr("Selected", "true");
                                                        $("#hdCheckNum").val(value);
                                                        $("#hdCheckNumName").val(Text);
                                                    }
                                                })
                                                $(".CheckNum_AutoComplete").next("input").val(Text);
                                            }
                                        });
                                    }
                                }
                                //判断是否已选过仓房信息
                                var Storelength = $(".Store_AutoComplete").length;
                                //alert(Storelength);
                                for (var i = 0; i < Storelength; i++) {
                                    if (i == 0) {
                                        var StoreID1 = $("#hdStore1").val();
                                        if (StoreID1 != "") {
                                            $.ajax({
                                                type: "Get",
                                                url: "../../Data/AutoComplete.ashx",
                                                data: "Function=GetStoreByGranaryID&GranaryID=" + GranaryID + "",
                                                success: function (storeInfo) {
                                                    //alert(storeInfo);
                                                    $("#ddl_Store_AutoComplete1").next("input").val("");
                                                    $("#ddl_Store_AutoComplete1").find("option").remove();

                                                    if (isStoreHouseCheckAll == "true") {
                                                        storeInfo = "<option value=\"QuanBu\" title=\"QuanBu\">--全部--</option>" + storeInfo;
                                                    }

                                                    $("#ddl_Store_AutoComplete1").append(storeInfo);
                                                    $(".Store_AutoComplete").combobox();
                                                    //选中并显示
                                                    Text = "";
                                                    $("#ddl_Store_AutoComplete1").find("option").map(function () {
                                                        var value = $(this).val();
                                                        if (value == StoreID1) {
                                                            Text = $(this).text();
                                                            //选项被选中
                                                            //$(this).attr("Selected", "true");
                                                            $("#hdStore1").val(value);
                                                            $("#hdStoreName1").val(Text);

                                                        }
                                                    });
                                                    $("#ddl_Store_AutoComplete1").next("input").val(Text);

                                                    //判断是否已选过时间信息
                                                    var TimeID1 = $("#hdTime1").val();

                                                    if (TimeID1 != "") {
                                                        $("#ddl_Time_AutoComplete1").next("input").val("");
                                                        $("#ddl_Time_AutoComplete1").find("option").remove();

                                                        $.ajax({
                                                            type: "Get",
                                                            url: "../../Data/AutoComplete.ashx",
                                                            data: "Function=GetTimeByGranaryIDStoreID&StoreID=" + StoreID1 + "&GranaryID=" + GranaryID + "",
                                                            success: function (timeInfo) {
                                                                //alert(timeInfo);
                                                                $("#ddl_Time_AutoComplete1").append(timeInfo);
                                                                $(".Time_AutoComplete").combobox();
                                                                //选中并显示
                                                                Text = "";
                                                                $("#ddl_Time_AutoComplete1").find("option").map(function () {
                                                                    var value = $(this).val();
                                                                    if (value == TimeID1) {
                                                                        Text = $(this).text();
                                                                        //选项被选中
                                                                        //$(this).attr("Selected", "true");
                                                                        $("#hdTime1").val(value);
                                                                        $("#hdTimeValue1").val(value);  //Text 和 value值相同
                                                                    }
                                                                });
                                                                $("#ddl_Time_AutoComplete1").next("input").val(Text);
                                                            }
                                                        });
                                                    }
                                                }
                                            });
                                        }
                                    }
                                    if (i == 1) {
                                        var StoreID2 = $("#hdStore2").val();

                                        if (StoreID2 != "") {
                                            $.ajax({
                                                type: "Get",
                                                url: "../../Data/AutoComplete.ashx",
                                                data: "Function=GetStoreByGranaryID&GranaryID=" + GranaryID + "",
                                                success: function (storeInfo) {
                                                    $("#ddl_Store_AutoComplete2").next("input").val("");
                                                    $("#ddl_Store_AutoComplete2").find("option").remove();

                                                    if (isStoreHouseCheckAll == "true") {
                                                        storeInfo = "<option value=\"QuanBu\" title=\"QuanBu\">--全部--</option>" + storeInfo;
                                                    }

                                                    $("#ddl_Store_AutoComplete2").append(storeInfo);
                                                    $(".Store_AutoComplete").combobox();

                                                    //选中并显示
                                                    Text = "";
                                                    $("#ddl_Store_AutoComplete2").find("option").map(function () {
                                                        var value = $(this).val();
                                                        if (value == StoreID2) {
                                                            Text = $(this).text();
                                                            //选项被选中
                                                            //$(this).attr("Selected", "true");
                                                            $("#hdStore2").val(value)
                                                            $("#hdStoreName2").val(Text)
                                                        }
                                                    });
                                                    $("#ddl_Store_AutoComplete2").next("input").val(Text);

                                                    //判断是否已选过时间信息
                                                    var TimeID2 = $("#hdTime2").val();

                                                    if (TimeID2 != "") {
                                                        $("#ddl_Time_AutoComplete2").next("input").val("");
                                                        $("#ddl_Time_AutoComplete2").find("option").remove();

                                                        $.ajax({
                                                            type: "Get",
                                                            url: "../../Data/AutoComplete.ashx",
                                                            data: "Function=GetTimeByGranaryIDStoreID&StoreID=" + StoreID2 + "&GranaryID=" + GranaryID + "",
                                                            success: function (timeInfo) {
                                                                //alert(timeInfo);
                                                                $("#ddl_Time_AutoComplete2").append(timeInfo);
                                                                $(".Time_AutoComplete").combobox();
                                                                //选中并显示
                                                                Text = "";
                                                                $("#ddl_Time_AutoComplete2").find("option").map(function () {
                                                                    var value = $(this).val();
                                                                    if (value == TimeID2) {
                                                                        Text = $(this).text();
                                                                        //选项被选中
                                                                        //$(this).attr("Selected", "true");
                                                                        $("#hdTime2").val(value);
                                                                        $("#hdTimeValue2").val(value);
                                                                    }
                                                                });
                                                                $("#ddl_Time_AutoComplete2").next("input").val(Text);
                                                            }
                                                        });
                                                    }
                                                }
                                            });
                                        }
                                    }
                                }
                            }
                            else {
                                if (isGranaryCheckAll == "true") {
                                    if ($("#hdGranary").val() == "" || $("#hdGranary").val() == "QuanBu") {
                                        $(".Granary_AutoComplete").next("input").val($(".Granary_AutoComplete").find("option").eq(0).text());
                                        $("#hdGranary").val($(".Granary_AutoComplete").find("option").eq(0).val());
                                        $("#hdGranaryName").val($(".Granary_AutoComplete").find("option").eq(0).text());
                                    }
                                }
                                else {
                                    $("#hdGranary").val($(".Granary_AutoComplete").find("option").eq(1).val());
                                    $("#hdGranaryName").val($(".Granary_AutoComplete").find("option").eq(1).text());
                                    $(".Granary_AutoComplete").next("input").val($(".Granary_AutoComplete").find("option").eq(1).text());
                                }
                            }
                        }
                    });
                }
            }
        }
    });
    if ($(".Type_AutoComplete").length) {
        $(".Type_AutoComplete").combobox();
    }
    if ($(".Type_AutoComplete1").length) {
        $(".Type_AutoComplete1").combobox();
    }



}
